ip 淘宝ip库 精简版
<?php
header('Content-type: text/html; charset=utf-8');
//根据ip获取城市、网络运营商等信息
function findCityByIp($ip){
$data = file_get_contents('http://ip.taobao.com/service/getIpInfo.php?ip='.$ip);
$result = json_decode($data,$assoc=true);
$city=$result['data']['region'];
$len = (strlen($city)-3)/3;
$cityname = mb_substr($city,0,$len,'utf-8');
return $cityname;
}
$ip = '27.184.128.234';
echo $aa = findCityByIp($ip);
?>