0

我无法通过 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
}

谢谢大家的回答。

4

1 回答 1

6
foreach($results as $key => $val){  
  $temp = current($val); # fetch first value, which is array in your example
  echo $temp['lat'];
}
于 2013-01-15T21:50:08.760 回答