3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array(); $l = 100000; for($i = 0; $i< $l; $i++) { $array[$i] = md5($i); } $copy = $array; $start = microtime(true); for($i = 0; $i< $l; $i++) { $copy[$i] = $copy[$i] . ' x'; usleep(1); } echo "\nfor:" . (microtime(true) - $start); $copy = $array; $start = microtime(true); foreach ($copy as $i => $item) { $copy[$i] = $item . ' x'; usleep(1); } echo "\nforeach (ohne ref):" . (microtime(true) - $start); $copy = $array; $start = microtime(true); foreach ($copy as &$item) { $item .= ' x'; usleep(1); } echo "\nforeach (mit ref):" . (microtime(true) - $start); $copy = $array; $start = microtime(true); array_walk($copy, function (&$item, $i) { $item .= ' x'; usleep(1); }); echo "\narray_walk (mit ref):" . (microtime(true) - $start); $copy = $array; $start = microtime(true); $copy = array_map(function ($item) { $item .= ' x'; usleep(1); return $item; }, $copy); echo "\narray_map (ohne ref):" . (microtime(true) - $start);
Output for 5.3.4 - 5.4.21

Process exited with code 137.
Output for 5.2.15 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/AuTSI on line 37
Process exited with code 255.