3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $classmap1 = array(); for ($i=1; $i<=10000; $i++) { $classmap1['a'.$i] = $i+1; } $classmap2 = array(); for ($i=1; $i<=10000; $i++) { $classmap2['b'.$i] = $i+1; } abstract class merging { public static function merge(array &$a, array &$b) { foreach ($b as $key => $value) { if (array_key_exists($key, $a)) { if (is_int($key)) { $a[] = $value; } elseif (is_array($value) && is_array($a[$key])) { $a[$key] = static::merge($a[$key], $value); } else { $a[$key] = $value; } } else { $a[$key] = $value; } } } } $startTimeFunc = microtime(true); merging::merge($classmap1, $classmap2); $endTimeFunc = microtime(true); echo "Func took " . (($endTimeFunc - $startTimeFunc)*1000) ." microseconds<br />\n"; //var_dump($am);
Output for 7.1.0
Func took 0.9160041809082 microseconds<br />
Output for 7.0.14
Func took 1.0840892791748 microseconds<br />
Output for 7.0.10
Func took 1.5778541564941 microseconds<br />
Output for 7.0.9
Func took 1.2121200561523 microseconds<br />
Output for 7.0.8
Func took 0.79798698425293 microseconds<br />
Output for 7.0.7
Func took 0.9770393371582 microseconds<br />
Output for 7.0.6
Func took 1.4119148254395 microseconds<br />
Output for 7.0.5
Func took 0.90384483337402 microseconds<br />
Output for 7.0.4
Func took 0.60486793518066 microseconds<br />
Output for 7.0.3
Func took 0.5791187286377 microseconds<br />
Output for 7.0.2
Func took 0.81682205200195 microseconds<br />
Output for 7.0.1
Func took 0.63085556030273 microseconds<br />
Output for 7.0.0
Func took 0.93221664428711 microseconds<br />
Output for 5.3.0 - 5.6.28

Process exited with code 137.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STATIC in /in/EH4DM on line 22
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/EH4DM on line 15
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/EH4DM on line 14
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_CLASS in /in/EH4DM on line 14
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/EH4DM on line 14
Process exited with code 255.