0

I have an array

Array
(
    [0] => Array
        (
            [0] => 3
            [1] => 8
            [2] => 4
            [3] => 1
            [4] => 6
            [5] => 5
            [6] => 9
            [7] => 13
            [8] => 25
            [9] => 26
            [10] => 14
            [11] => 7
            [12] => 27
            [13] => 10
        )

    [1] => Array
        (
            [0] => 12
        )

)

which I want to convert to a single array -

array(3,8,4,1 ...,27,10, 12);

I've tried array_merge_recursive($arrayProduct); and array_merge but can't get either of them to work

user1616338
  • 557
  • 1
  • 8
  • 24
  • 1
    Does this answer your question? [How to "flatten" a multi-dimensional array to simple one in PHP?](https://stackoverflow.com/questions/526556/how-to-flatten-a-multi-dimensional-array-to-simple-one-in-php) – El_Vanja Feb 24 '21 at 16:19
  • 2
    Take a look at [this answer specifically](https://stackoverflow.com/a/53891086/4205384). It provides a contemporary and simple solution. – El_Vanja Feb 24 '21 at 16:19
  • What's wrong with common `array_merge()`? `$arr = [ [3, 8, 4, 1, 6, 5, 0, 13, 25, 26, 14, 7, 27, 10], [12] ]; var_dump(array_merge($arr[0], $arr[1]));` – biesior Feb 24 '21 at 16:22
  • The array-merge won't work because I don't know the dimensions of the array – user1616338 Feb 24 '21 at 16:26
  • @El_Vanja - that worked perfectly (after I got my head around how it works :) – user1616338 Feb 24 '21 at 16:27

0 Answers0