dome.php
//$ip = "119.129.245.106"; //广州
$ip = "183.12.197.142"; //深圳
$ip = "183.247.161.185";
//杭州
$url =
"http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=$ip";
$fArr = file_get_contents($url);
//echo $fArr;
//{"ret":1,"start":"183.247.128.0","end":"183.247.191.255","country":"\u4e2d\u56fd","province":"\u6d59\u6c5f","city":"\u676d\u5dde","district":"","isp":"\u79fb\u901a","type":"","desc":""}
$json
= json_decode($fArr, true); //对json数据进行 JSON
编码
//print_r($json); //Array
( [ret] => 1 [start] => 183.247.128.0 [end] => 183.247.191.255
[country] => 中国 [province] => 浙江 [city] => 杭州 [district] => [isp]
=> 移通 [type] => [desc] => ) 对json数据 进行 JSON编码
返回值:array;
echo
"归属地:".$json["country"].$json["province"].$json["city"].$json["district"].$json["isp"];
//归属地:中国浙江杭州移通
原文:http://www.cnblogs.com/xy404/p/3582836.html