3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_unpack(array $arg1, array $arg2) { return [...$arg1, ...$arg2]; } $arr1 = range(1, 100); $arr2 = array_combine(range('a', chr(ord('a') + 99)), range(1, 100)); $max = 10000; $start = microtime(true); for ($i = 0; $i < $max; $i++) { $res1 = array_merge($arr1, $arr2); } print("array_merge:\n"); printf("Took %.7f seconds per execution\n", (microtime(true) - $start) / $max); $max = 10000; $start = microtime(true); for ($i = 0; $i < $max; $i++) { $res2 = array_unpack($arr1, $arr2); } print("array_unpack:\n"); printf("Took %.7f seconds per execution\n", (microtime(true) - $start) / $max); assert($res1 === $res2);

preferences:
44.68 ms | 410 KiB | 5 Q