use*_*467 0 php arrays foreach
我有一个问题是获取数组值"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"
}
}
Run Code Online (Sandbox Code Playgroud)
}
功能:
foreach($results as $key => $val){
//here i want to reach lat and long without additional foreach loop
}
Run Code Online (Sandbox Code Playgroud)
谢谢大家的答案.
foreach($results as $key => $val){
$temp = current($val); # fetch first value, which is array in your example
echo $temp['lat'];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1586 次 |
| 最近记录: |