$url = 'http://api.map.baidu.com/geocoder?address=广东省广州市海珠区&output=json'; $result = file_get_contents($url); $json = json_decode($result,true); $var = $json['result']['location']; var_dump($json); array(2) { ["status"]=> string(2) "OK" ["result"]=> array(4) { ["location"]=> array(2) { ["lng"]=> float(113.32354) ["lat"]=> float(23.088981) } ["precise"]=> int(0) ["confidence"]=> int(20) ["level"]=> string(6) "区县" } }
var_dump($var);
array(2) {
["lng"]=>
float(113.32354)
["lat"]=>
float(23.088981)
}