dreamwest Posted May 7, 2009 Share Posted May 7, 2009 Im trying to display a website url without the supplied subdirectories and http:// Example url: http://sitename.com/dir/A/02/?extras=MTM0MjQ6Mzo2,0,0,0,194 What i need: sitename Quote Link to comment https://forums.phpfreaks.com/topic/157204-strip-a-url-down/ Share on other sites More sharing options...
papaface Posted May 7, 2009 Share Posted May 7, 2009 <?php $url = parse_url('http://sitename.com/dir/A/02/?extras=MTM0MjQ6Mzo2,0,0,0,194'); echo $url['host']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/157204-strip-a-url-down/#findComment-828348 Share on other sites More sharing options...
dreamwest Posted May 7, 2009 Author Share Posted May 7, 2009 Awesome. Works well Can this be adjusted to remove subdomains like this: http://subdomain.sitename.com/dir/A/02/?extras=MTM0MjQ6Mzo2,0,0,0,194 Quote Link to comment https://forums.phpfreaks.com/topic/157204-strip-a-url-down/#findComment-828354 Share on other sites More sharing options...
trq Posted May 7, 2009 Share Posted May 7, 2009 Yes, look at strpos and substr. Quote Link to comment https://forums.phpfreaks.com/topic/157204-strip-a-url-down/#findComment-828360 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.