Source Code:
(back to article)
<?php $numbers = array(array(1, 2), array(3, 4), array(5)); $flat = array_reduce($numbers, function($carry, $item) { return array_merge($carry, $item); }, array()); print_r($flat); // Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) ?>
Result:
Report an issue