Tomi Seus Tomi Seus - 4 months ago 8
PHP Question

Turning multidimensional array into one-dimensional array

I've been banging my head on this one for a while now.

I have this multidimensional array:

Array
(
[0] => Array
(
[0] => foo
[1] => bar
[2] => hello
)

[1] => Array
(
[0] => world
[1] => love
)

[2] => Array
(
[0] => stack
[1] => overflow
[2] => yep
[3] => man
)


And I need to get this:

Array
(
[0] => foo
[1] => bar
[2] => hello
[3] => world
[4] => love
[5] => stack
[6] => overflow
[7] => yep
[8] => man
)


Any ideas?

All other solutions I found solve multidimensional arrays with different keys. My arrays use simple numeric keys only.

Answer

SOLUTION: I used hakre's solution, even though I tried deceze's solution too and it works as well. I wrote:

$flat = call_user_func_array('array_merge', $array);

Simple.