hi, i need a php function to extract domain with tld from a url or domain with tld and subdomain if there is.
example:
http://minova.tumblr.com/post/145515 >> minova.tumblr.com
http://www.tumblr.com/about/1 >> tumblr.com
Thanks
hi, i need a php function to extract domain with tld from a url or domain with tld and subdomain if there is.
example:
http://minova.tumblr.com/post/145515 >> minova.tumblr.com
http://www.tumblr.com/about/1 >> tumblr.com
Thanks
http://php.net/manual/en/function.parse-url.php - special focus on 'host' and 'path'.
$var = "http://minova.tumblr.com/post/145515";
print_r(parse_url($var));
Outputs:
array (
'scheme' => 'http',
'host' => 'minova.tumblr.com',
'path' => '/post/145515',
)
$var = "http://minova.tumblr.com/post/145515";
print parse_url($var, PHP_URL_HOST);
Outputs:
minova.tumblr.com