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 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']; ?> 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 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. Link to comment https://forums.phpfreaks.com/topic/157204-strip-a-url-down/#findComment-828360 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.