get tdl with domain
function get_tdl($url) { // strip http:// and www. $tld = preg_replace("/^(https?:\/\/)?(www\.)?/i", "", $url); // strip everything else $tld = preg_replace("/\/.*$/", "", $tld); // extract and return tld $tld = substr($tld, strrpos($tld, ".") + 1); return $tld; }