时间:2021-07-01 10:21:17 帮助过:19人阅读
$ipAddr = "4.4.44.4";
$ipChinazAddr = "http://tool.chinaz.com/IP/?IP=".$ipAddr;
$contents = file_get_contents($ipChinazAddr);
$pattern = "/==>>.+
/";
$string = $contents;
preg_match_all($pattern,$string,$addrArray);
$num = count($addrArray[0]);
$pattern = "/(==>>).+(==>>s)/";
for($i = 0;$i<$num;$i++){
$addrArray[0][$i] = preg_replace($pattern,"",$addrArray[0][$i]);
}
echo "";";
print_r($addrArray);
echo "
?>
http://www.bkjia.com/PHPjc/444762.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444762.htmlTechArticle一个IP获取的结果不是很完善,究其原因是因为ip138的IP解析应对国外的地址时不是很详细,所以又重新写了个用Chianz.com的代码。 !DOCTYPE h...