-2

How would i flatten the following array. I want to get rid of 0 and 1, and just have 0-5 as they keys. I am using php by the way.

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
                )

        )

)
Lawrence Cherone
  • 46,049
  • 7
  • 62
  • 106
  • 1
    Fix the way you make the array, dont do it twice, [XY Problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) – Lawrence Cherone Jul 19 '14 at 18:25
  • possible duplicate of [How to Flatten a Multidimensional Array?](http://stackoverflow.com/questions/1319903/how-to-flatten-a-multidimensional-array) – Hanky Panky Jul 20 '14 at 04:19

1 Answers1

0
$flatArray = array();

foreach ($array as $l1Array){
  foreach ($l1Array as $k => $v){
    $flatArray[]=$v;
  } 
}
andrew
  • 9,313
  • 7
  • 30
  • 61