Yes you are right . its not look good , -
jagdish
Sep 30 '16 07:50
$url="http://hostname.com/contact-us.html";
echo $domain = strstr(substr(strstr($url, '//'),2),"/",true);// try it on >=php 5.3.0
hostname.com
$url="http://hostname.com/contact-us.html";
strstr()
//hostname.com/contact-us.html
hostname.com/contact-us.html
hostname.com
$url="http://hostname.com/contact-us.html";
preg_match('@^(?:http://|https://)?([^/]+)@i',$url, $matches);
echo $host = $matches[1];
hostname.com