Simplest way to flatten two-dimension array

Among many different ways to flatten multidimensional array, I found this one as the cleanest one:

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

It works for two-dimension arrays only (!), but in most cases, we operate on such. If you’re working on an array with more dimensions or for some reason don’t like this solution, then pick any among above linked.

Leave a Reply