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; } } return $a; } } $startTimeFunc = microtime(true); $am = 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 1.1069774627686 microseconds<br />
Output for 7.0.14
Func took 1.0828971862793 microseconds<br />
Output for 7.0.10
Func took 1.262903213501 microseconds<br />
Output for 7.0.9
Func took 1.2681484222412 microseconds<br />
Output for 7.0.8
Func took 1.4090538024902 microseconds<br />
Output for 7.0.7
Func took 0.91195106506348 microseconds<br />
Output for 7.0.6
Func took 1.1358261108398 microseconds<br />
Output for 7.0.5
Func took 1.0001659393311 microseconds<br />
Output for 7.0.4
Func took 1.082181930542 microseconds<br />
Output for 7.0.3
Func took 0.66304206848145 microseconds<br />
Output for 7.0.2
Func took 0.90789794921875 microseconds<br />
Output for 7.0.1
Func took 0.81801414489746 microseconds<br />
Output for 7.0.0
Func took 1.0859966278076 microseconds<br />
Output for hhvm-3.12.0
Func took 1.7938613891602 microseconds<br />
Output for hhvm-3.10.0
Func took 2.3729801177979 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/9WYl1 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/9WYl1 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/9WYl1 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/9WYl1 on line 14
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/9WYl1 on line 14
Process exited with code 255.