1 $getIp=‘175.25.25.136‘; 2 echo ‘IP:‘,$getIp; 3 echo ‘<br/>‘; 4 $content = file_get_contents("http://api.map.baidu.com/location/ip?ak=7IZ6fgGEGohCrRKUE9Rj4TSQ&ip={$getIp}&coor=bd09ll"); 5 $json = json_decode($content); 6 echo ‘<pre>‘; 7 print_r($json); 8 9 echo ‘log:‘,$json->{‘content‘}->{‘point‘}->{‘x‘};//按层级关系提取经度数据 10 echo ‘<br/>‘; 11 echo ‘lat:‘,$json->{‘content‘}->{‘point‘}->{‘y‘};//按层级关系提取纬度数据 12 echo ‘<br/>‘; 13 print $json->{‘content‘}->{‘address‘};//按层级关系提取address数据
原文:http://www.cnblogs.com/mljun/p/5554580.html