function getLoLa($add) { $baiduAK = 'https://api.map.baidu.com/geocoding/v3/?address=' . $add . '&output=json&ak=11Z8uiP8kIz6AG0Vjiwzbc5f9Ii0cdHd&callback=showLocation'; $lola = file_get_contents($baiduAK); return $lola; } function strRe($str) { $b = str_replace('showLocation&&showLocation', '', $str); $b = str_replace('(', '', $b); $b = str_replace(')', '', $b); $c = json_decode($b, true); return $c; } echo "<pre>"; $a = strRe(getLoLa('宁波市鄞州区泰康中路558号')); //var_dump($a); echo $a["result"]["location"]["lng"]; echo "<br>"; echo $a["result"]["location"]["lat"]; //var_dump($a); /*echo "<hr>"; var_dump($a);*/