如何打印多维数组值

时间:2015-06-04 09:26:33

标签: php arrays multidimensional-array

这是数组值

 $value = Array (
      [0] => Array (
        [A] => -33.884667407851
        [F] => 151.16123199463
      ) 
      [1] => Array (
        [A] => -33.876686661215
        [F] => 151.20414733887
      )   
    )

这是我的数组,我想要像这样的输出

[[-33.866139529765626,151.26079559326172],[ - 33.866139529765626,151.26903533935547]]

2 个答案:

答案 0 :(得分:2)

这样就可以了,

$your_array = array (
  0 => array (
    'A' => -33.884667407851,
    'F' => 151.16123199463
  ) ,
  1 => array (
    'A' => -33.876686661215,
    'F' => 151.20414733887
  )   
);


$your_output = json_encode(array_map('array_values', $your_array));

输出:

[[-33.884667407851,151.16123199463],[-33.876686661215,151.20414733887]]

答案 1 :(得分:0)

尝试($foo是您的起始数组):

$result = array();
foreach ($foo as $arr) {
    $new_arr = array();
    foreach ($arr as $key => $val) {
        array_push($new_arr, $val);
    }
    array_push($result, $new_arr);
}

print_r($result);