Guest Posted February 24, 2007 Share Posted February 24, 2007 How can I get the domain http://www.whatever.com from a string that contains http://www.whatever.com/site/what.php Link to comment https://forums.phpfreaks.com/topic/39955-solved-top-domain-from-string/ Share on other sites More sharing options...
sandrob57 Posted February 24, 2007 Share Posted February 24, 2007 I think its $BASEDIR, or some spin off of that. Link to comment https://forums.phpfreaks.com/topic/39955-solved-top-domain-from-string/#findComment-193171 Share on other sites More sharing options...
Guest Posted February 24, 2007 Share Posted February 24, 2007 I need it to pull the domain out of the string though Link to comment https://forums.phpfreaks.com/topic/39955-solved-top-domain-from-string/#findComment-193175 Share on other sites More sharing options...
magic2goodil Posted February 24, 2007 Share Posted February 24, 2007 $_SERVER['HTTP_HOST']; Link to comment https://forums.phpfreaks.com/topic/39955-solved-top-domain-from-string/#findComment-193177 Share on other sites More sharing options...
Guest Posted February 24, 2007 Share Posted February 24, 2007 I need it to out of a string that contains an address not the address bar. Link to comment https://forums.phpfreaks.com/topic/39955-solved-top-domain-from-string/#findComment-193179 Share on other sites More sharing options...
Jessica Posted February 24, 2007 Share Posted February 24, 2007 You'll need to use a regular expression, likely. Or you can check if the first substring is http:// then just go to the next /, and that is http://www.domain.com/ If it's not, it's just www.domain.com Link to comment https://forums.phpfreaks.com/topic/39955-solved-top-domain-from-string/#findComment-193180 Share on other sites More sharing options...
magic2goodil Posted February 24, 2007 Share Posted February 24, 2007 oops, sorry, misread what u needed. <?php $url = "http://www.whatever.com/site/what.php"; $domain = substr($url, strpos($url, "//")+2, strlen($url)); $domain = substr($domain, 0, strpos($domain, "/")); $domain = "http://".$domain; echo $domain; ?> Link to comment https://forums.phpfreaks.com/topic/39955-solved-top-domain-from-string/#findComment-193188 Share on other sites More sharing options...
Guest Posted February 25, 2007 Share Posted February 25, 2007 Thank You that worked wonders. Link to comment https://forums.phpfreaks.com/topic/39955-solved-top-domain-from-string/#findComment-193471 Share on other sites More sharing options...
magic2goodil Posted February 25, 2007 Share Posted February 25, 2007 Well then as the french may or may not say...le w00t Link to comment https://forums.phpfreaks.com/topic/39955-solved-top-domain-from-string/#findComment-193487 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.