I have url like http://www.domain.com/some/somepage.html and want to get the www.domain.com form the string. The eregs are crazy, crazy crazy! I am sitting on it few hours and cant get it
if it is the URL of the page you are on then you can use the php variable $HTTP_HOST
No, I cant use it, because I have this link "as is" in my database and need to work with it
Try the following:
$url = "http://www.domain.com/some/somepage.html"; $url_parts = parse_url($url); echo $url_parts["host"];
Look for more info here: http://www.php.net/manual/en/function.parse-url.php
Thanks! Parse url work!