[英]PHP multidimensional array - foreach loop
我在獲取數組值“ lat”和“ long”而又不通過foreach函數更深入的問題。 數組:
array(1) {
["Berlin, Germany(All airports)"]=>
array(1) {
["Berlin Brandenburg Willy Brandt(BER)"]=>
array(2) {
["lat"]=>
string(9) "52.366667"
["lon"]=>
string(9) "13.503333"
}
}
}
功能:
foreach($results as $key => $val){
//here i want to reach lat and long without additional foreach loop
}
謝謝大家的回答。
foreach($results as $key => $val){
$temp = current($val); # fetch first value, which is array in your example
echo $temp['lat'];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.