3v4l.org

run code in 300+ PHP versions simultaneously
<?php $all = []; for( $i=0; $i<2000; $i++ ) { for( $j=0; $j<800; $j++ ) { $all[$i][$j] = $j; } } $start = microtime(true); $mergedArray = array_merge(...$all); echo PHP_EOL . 'Array merge time: ' . microtime(true); $mergedArray = []; $start = microtime(true); foreach($all as &$templateClosingArray) { $mergedArray += $templateClosingArray; } echo PHP_EOL . 'Union time: ' . microtime(true);
Output for 8.2.18 - 8.2.29, 8.3.5 - 8.3.27, 8.4.1 - 8.4.14
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/Tu29N on line 12
Process exited with code 255.
Output for 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Out of memory (allocated 31457280 bytes) (tried to allocate 20480 bytes) in /in/Tu29N on line 6 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.

preferences:
45.87 ms | 407 KiB | 5 Q