<?php
function get_ip_place(){
$ip=file_get_contents("http://fw.qq.com/ipaddress");
$ip=str_replace('"',' ',$ip);
$ip2=explode("(",$ip);
$a=substr($ip2[1],0,-2);
$b=explode(",",$a);
return $b;
}
$ip=get_ip_place();
print_r($ip);
?>
必须在联网的条件下使用,使用腾迅的一个api,即http://fw.qq.com/ipaddress,打开这个地址看看:var IPData = new Array("117.80.36.111","","江苏省","苏州市");
然后用php进行了简单的处理,使返回的结果用数组形式显示:
即Array ( [0] =>117.80.36.111 [1] => [2] => 江苏省 [3] => 苏州市)