3v4l.org

run code in 300+ PHP versions simultaneously
<?php $iter = 100; $array = range(0, $iter); $function = function($val, $key) {}; $t = microtime(true); for($i = 0; $i < $iter; $i++) { foreach($array as $key => $val) { $function($val, $key); } } echo 'foreach: '.(microtime(true) - $t); $t = microtime(true); for($i = 0; $i < $iter; $i++) { array_walk($array, $function); } echo ', array_walk: '.(microtime(true) - $t); $t = microtime(true); for($i = 0; $i < $iter; $i++) { array_map($function, $array); } echo ', array_map: '.(microtime(true) - $t).'\n';

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.2.00.0040.01219.49
7.1.70.0030.00517.38
7.1.60.0070.02119.17
7.1.50.0030.01016.91
7.0.200.0030.00616.68

preferences:
30.58 ms | 400 KiB | 5 Q