2013-03-15 79 views
0

我有一個問題,我不明白我怎麼能得到的「生成陣列寫這個劇本address_components領域LONG_NAME例如:讀陣列谷歌地圖

$url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='.$lat.','.$lng.'&sensor=true'; 
$data = @file_get_contents($url); 
$jsondata = json_decode($data , true); 

if(is_array($jsondata)) 
{ 
     $long_name= $jsondata ['results']['address_components'][0]['long_name']; 
} 

看起來建議

謝謝

回答

0

$results是一個數組。如果你想得到第一個結果:

$jsondata ['results'][0]['address_components'][0]['long_name']