嗨,這個數組包含不止一個國家的事件,我怎麼能循環放出所有這些?如何通過數組循環?
$url = 'http://maps.googleapis.com/maps/api/geocode/json?address=cordoba';
$json = @file_get_contents($url);
$jsondata = json_decode($json);
$status = $jsondata->status;
$address = '';
if($status == "OK")
{
$address_data = $jsondata->results[0]->address_components;
print_r($address_data);
//echo $address_data[3]->long_name;
}
else
{
echo "No Data Found Try Again";
}
一種方法是使用'的foreach()'http://php.net/manual/en/control-structures.foreach.php –
能否請您分享一些代碼,我是那種如果新手在此? – letsforum
你也可以閱讀更多關於這個副本:http://stackoverflow.com/questions/4414623/loop-through-an-array-php –