如何将一个三维数组平展到二维



如何将下面的数组平整化?我想把0和1消掉,只留下0-5作为键。顺便说一下,我正在使用php。

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [id] => 182
                )
            [1] => Array
                (
                    [id] => 183
                )
            [2] => Array
                (
                    [id] => 185
                )
            [3] => Array
                (
                    [id] => 184
                )
            [4] => Array
                (
                    [id] => 186
                )
        )
    [1] => Array
        (
            [0] => Array
                (
                    [id] => 171
                )
        )
)
$flatArray = array();
foreach ($array as $l1Array){
  foreach ($l1Array as $k => $v){
    $flatArray[]=$v;
  } 
}

相关内容

  • 没有找到相关文章

最新更新