2017-02-11 86 views
0

請問我在做什麼錯誤時瀏覽數組?我需要使用php和json響應來獲得緯度。 預先感謝您。JSON谷歌地圖陣列

$googleurl='https://maps.googleapis.com/maps/api/geocode/json?address=Prague'; 
$json=file_get_contents($googleurl); 
$res=json_encode($json, true); 
print $res['results'][0]['geometry']['location']['lat']; 

回答

0

您需要解碼json不編碼。

使用try,

$res=json_decode($json, true);