我在使用foreach函数获取数组值“lat”和“long”时遇到问题。阵列:
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
}
谢谢大家的回答。
答案 0 :(得分:6)
foreach($results as $key => $val){
$temp = current($val); # fetch first value, which is array in your example
echo $temp['lat'];
}