Reputation: 8647
I'm looking for a bullet proof way to extract domain (with tld) from any given link - an eqivalent of dirname($path)
let's call it domainname($link).
echo domainname("http://example.com/index.html?a=123%1231");
should print "example.com"
Upvotes: 2
Views: 1751
Reputation: 1462
echo parse_url($url, PHP_URL_HOST);
More info: http://be.php.net/manual/en/function.parse-url.php
Upvotes: 8