$url = trim($url);
$url = preg_replace(“/^(http:\/\/)*(www.)*/is”, “”, $url);
$url = preg_replace(“/\/.*$/is”, “”, $url);
return $url;

2 thoughts on “Get domain name from url”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.