3v4l.org

run code in 300+ PHP versions simultaneously
<?php $prefixes = array( 'aaa' => true, 'bbb' => true, 'ccc' => true, 'ddd' => true, ); $array = array(); for ($i = 0; $i < 50; $i++) { $values = array(); for ($j = 0; $j < 5000; $j++) { $values[array_rand($prefixes).$j] = mt_rand(0, 1000); } $array[$i] = $values; } $t = microtime(1); $result1 = array(); foreach ($array as $v) { $result1 = array_merge($result1, $v); } echo 'multiple: '.(microtime(1) - $t)."\n"; $t = microtime(1); $result2 = call_user_func_array('array_merge', $array); echo 'single: '.(microtime(1) - $t)."\n";

preferences:
26.94 ms | 407 KiB | 5 Q