具体如下:
= 0; $i --) {
if ($i == 0) {
// just in case of something like NAME.COM
break;
}
if (in_array ( $sub_domain [$i], $iana_root )) {
$top_domain_count ++;
$top_domain = '.' . $sub_domain [$i] . $top_domain;
if ($top_domain_count >= 2) {
break;
}
}
}
$top_domain = $sub_domain [count ( $sub_domain ) - $top_domain_count - 1] . $top_domain;
return $top_domain;
}
echo top_domain("http://tools.jb51.net/");
?>