php/ gethostbyname() IP取得 ドメインを取得する
$subdomain = preg_replace("/https?:\/\//iu", "", $row["url"]);
if(
$tmp = preg_split("/\//u", $subdomain)
){
$subdomain = $tmp[0];
} else{
$subdomain = $row["url"];
}
//print_r($tmp);
$ip = "";
if(
preg_match("/([-a-z0-9]+\\.[a-z]+)$/iu", $subdomain, $match)
){
$ip = gethostbyname($match[1]);
}
if(
preg_match("/^[0-9.]+$/u", $ip)
){
$subdomain = $match[1];
} elseif(
preg_match("/([-a-z0-9]+\\.[a-z]+\\.[a-z]+)$/iu", $subdomain, $match)
){
$ip = gethostbyname($match[1]);
if(
preg_match("/^[0-9.]+$/u", $ip)
){
$subdomain = $match[1];
}
}
( Thanks. )
gethostbyname
http://www.php.net/manual/ja/function.gethostbyname.php