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; } $startTimeMerge = microtime(true); $map = array_merge($classmap1, $classmap2); $endTimeMerge = microtime(true); function amerge(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; } $startTimeForeach = microtime(true); amerge($classmap1, $classmap2); $endTimeForeach = microtime(true); echo "Merging took " . (($endTimeMerge - $startTimeMerge)*1000) ." microseconds<br />\n"; echo "Foreach took " . (($endTimeForeach - $startTimeForeach)*1000) ." microseconds<br />\n";
Output for 5.6.28
Merging took 2.5198459625244 microseconds<br /> Foreach took 6.8330764770508 microseconds<br />
Output for 5.6.25
Merging took 2.7129650115967 microseconds<br /> Foreach took 6.9589614868164 microseconds<br />
Output for 5.6.24
Merging took 2.5680065155029 microseconds<br /> Foreach took 6.9148540496826 microseconds<br />
Output for 5.6.23
Merging took 2.4030208587646 microseconds<br /> Foreach took 6.55198097229 microseconds<br />
Output for 5.6.22
Merging took 2.5599002838135 microseconds<br /> Foreach took 6.0591697692871 microseconds<br />
Output for 5.6.21
Merging took 2.0129680633545 microseconds<br /> Foreach took 5.5749416351318 microseconds<br />
Output for 5.6.20
Merging took 2.6540756225586 microseconds<br /> Foreach took 7.1210861206055 microseconds<br />
Output for 5.6.19
Merging took 2.0508766174316 microseconds<br /> Foreach took 5.3770542144775 microseconds<br />
Output for 5.6.18
Merging took 2.2971630096436 microseconds<br /> Foreach took 5.6450366973877 microseconds<br />
Output for 5.6.17
Merging took 2.3400783538818 microseconds<br /> Foreach took 6.0179233551025 microseconds<br />
Output for 5.6.16
Merging took 2.3930072784424 microseconds<br /> Foreach took 6.3037872314453 microseconds<br />
Output for 5.6.15
Merging took 2.1741390228271 microseconds<br /> Foreach took 5.5270195007324 microseconds<br />
Output for 5.6.14
Merging took 2.5479793548584 microseconds<br /> Foreach took 6.7100524902344 microseconds<br />
Output for 5.6.13
Merging took 2.0689964294434 microseconds<br /> Foreach took 5.620002746582 microseconds<br />
Output for 5.6.12
Merging took 2.1679401397705 microseconds<br /> Foreach took 5.1770210266113 microseconds<br />
Output for 5.6.11
Merging took 2.3219585418701 microseconds<br /> Foreach took 5.281925201416 microseconds<br />
Output for 5.6.10
Merging took 2.3069381713867 microseconds<br /> Foreach took 6.2649250030518 microseconds<br />
Output for 5.6.9
Merging took 1.9919872283936 microseconds<br /> Foreach took 5.3601264953613 microseconds<br />
Output for 5.6.8
Merging took 2.6211738586426 microseconds<br /> Foreach took 6.7920684814453 microseconds<br />
Output for 5.6.7
Merging took 2.7718544006348 microseconds<br /> Foreach took 6.5150260925293 microseconds<br />
Output for 5.6.6
Merging took 2.6109218597412 microseconds<br /> Foreach took 5.8939456939697 microseconds<br />
Output for 5.6.5
Merging took 2.1710395812988 microseconds<br /> Foreach took 5.640983581543 microseconds<br />
Output for 5.6.4
Merging took 2.2599697113037 microseconds<br /> Foreach took 6.4671039581299 microseconds<br />
Output for 5.6.3
Merging took 2.2039413452148 microseconds<br /> Foreach took 5.842924118042 microseconds<br />
Output for 5.6.2
Merging took 2.4528503417969 microseconds<br /> Foreach took 6.2761306762695 microseconds<br />
Output for 5.6.1
Merging took 2.7091503143311 microseconds<br /> Foreach took 6.7141056060791 microseconds<br />
Output for 5.6.0
Merging took 2.2940635681152 microseconds<br /> Foreach took 4.78196144104 microseconds<br />
Output for 5.5.38
Merging took 3.6230087280273 microseconds<br /> Foreach took 9.4590187072754 microseconds<br />
Output for 5.5.37
Merging took 2.7871131896973 microseconds<br /> Foreach took 8.249044418335 microseconds<br />
Output for 5.5.36
Merging took 2.8369426727295 microseconds<br /> Foreach took 5.9559345245361 microseconds<br />
Output for 5.5.35
Merging took 2.7601718902588 microseconds<br /> Foreach took 7.3339939117432 microseconds<br />
Output for 5.5.34
Merging took 2.5990009307861 microseconds<br /> Foreach took 6.3450336456299 microseconds<br />
Output for 5.5.33
Merging took 2.2709369659424 microseconds<br /> Foreach took 5.7580471038818 microseconds<br />
Output for 5.5.32
Merging took 2.6328563690186 microseconds<br /> Foreach took 6.915807723999 microseconds<br />
Output for 5.5.31
Merging took 1.9989013671875 microseconds<br /> Foreach took 6.0660839080811 microseconds<br />
Output for 5.5.30
Merging took 2.4549961090088 microseconds<br /> Foreach took 6.3650608062744 microseconds<br />
Output for 5.5.29
Merging took 2.8729438781738 microseconds<br /> Foreach took 7.2939395904541 microseconds<br />
Output for 5.5.28
Merging took 2.310037612915 microseconds<br /> Foreach took 6.1068534851074 microseconds<br />
Output for 5.5.27
Merging took 1.8150806427002 microseconds<br /> Foreach took 4.8270225524902 microseconds<br />
Output for 5.5.26
Merging took 2.3541450500488 microseconds<br /> Foreach took 6.1650276184082 microseconds<br />
Output for 5.5.25
Merging took 2.4681091308594 microseconds<br /> Foreach took 6.2930583953857 microseconds<br />
Output for 5.5.24
Merging took 1.9569396972656 microseconds<br /> Foreach took 4.9750804901123 microseconds<br />
Output for 5.5.23
Merging took 2.0089149475098 microseconds<br /> Foreach took 5.2440166473389 microseconds<br />
Output for 5.5.22
Merging took 2.0880699157715 microseconds<br /> Foreach took 5.4800510406494 microseconds<br />
Output for 5.5.21
Merging took 2.755880355835 microseconds<br /> Foreach took 6.3509941101074 microseconds<br />
Output for 5.5.20
Merging took 2.5179386138916 microseconds<br /> Foreach took 6.4871311187744 microseconds<br />
Output for 5.5.19
Merging took 2.3140907287598 microseconds<br /> Foreach took 6.1159133911133 microseconds<br />
Output for 5.5.18
Merging took 2.3360252380371 microseconds<br /> Foreach took 6.1631202697754 microseconds<br />
Output for 5.5.16
Merging took 2.6991367340088 microseconds<br /> Foreach took 6.8259239196777 microseconds<br />
Output for 5.5.15
Merging took 2.377986907959 microseconds<br /> Foreach took 6.2859058380127 microseconds<br />
Output for 5.5.14
Merging took 2.129077911377 microseconds<br /> Foreach took 6.0908794403076 microseconds<br />
Output for 5.5.13
Merging took 2.723217010498 microseconds<br /> Foreach took 7.1098804473877 microseconds<br />
Output for 5.5.12
Merging took 2.4709701538086 microseconds<br /> Foreach took 5.3601264953613 microseconds<br />
Output for 5.5.11
Merging took 2.4850368499756 microseconds<br /> Foreach took 6.1409473419189 microseconds<br />
Output for 5.5.10
Merging took 2.2900104522705 microseconds<br /> Foreach took 6.2248706817627 microseconds<br />
Output for 5.5.9
Merging took 2.6600360870361 microseconds<br /> Foreach took 6.8769454956055 microseconds<br />
Output for 5.5.8
Merging took 2.4058818817139 microseconds<br /> Foreach took 6.3450336456299 microseconds<br />
Output for 5.5.7
Merging took 2.0208358764648 microseconds<br /> Foreach took 5.2530765533447 microseconds<br />
Output for 5.5.6
Merging took 2.6919841766357 microseconds<br /> Foreach took 7.2219371795654 microseconds<br />
Output for 5.5.5
Merging took 3.9119720458984 microseconds<br /> Foreach took 4.5351982116699 microseconds<br />
Output for 5.5.4
Merging took 4.7240257263184 microseconds<br /> Foreach took 6.2010288238525 microseconds<br />
Output for 5.5.3
Merging took 7.6930522918701 microseconds<br /> Foreach took 10.734081268311 microseconds<br />
Output for 5.5.2
Merging took 4.8458576202393 microseconds<br /> Foreach took 5.1331520080566 microseconds<br />
Output for 5.5.1
Merging took 4.5289993286133 microseconds<br /> Foreach took 5.6960582733154 microseconds<br />
Output for 5.5.0
Merging took 4.8189163208008 microseconds<br /> Foreach took 6.1628818511963 microseconds<br />
Output for 5.4.45
Merging took 3.9260387420654 microseconds<br /> Foreach took 5.3260326385498 microseconds<br />
Output for 5.4.44
Merging took 5.4688453674316 microseconds<br /> Foreach took 6.7138671875 microseconds<br />
Output for 5.4.43
Merging took 4.6160221099854 microseconds<br /> Foreach took 5.7721138000488 microseconds<br />
Output for 5.4.42
Merging took 4.371166229248 microseconds<br /> Foreach took 5.1560401916504 microseconds<br />
Output for 5.4.41
Merging took 5.317211151123 microseconds<br /> Foreach took 6.415843963623 microseconds<br />
Output for 5.4.40
Merging took 5.0840377807617 microseconds<br /> Foreach took 5.7780742645264 microseconds<br />
Output for 5.4.39
Merging took 4.9910545349121 microseconds<br /> Foreach took 6.0539245605469 microseconds<br />
Output for 5.4.38
Merging took 5.2030086517334 microseconds<br /> Foreach took 6.1399936676025 microseconds<br />
Output for 5.4.37
Merging took 4.6539306640625 microseconds<br /> Foreach took 5.7859420776367 microseconds<br />
Output for 5.4.36
Merging took 5.47194480896 microseconds<br /> Foreach took 6.7310333251953 microseconds<br />
Output for 5.4.35
Merging took 5.6159496307373 microseconds<br /> Foreach took 6.7739486694336 microseconds<br />
Output for 5.4.34
Merging took 4.4221878051758 microseconds<br /> Foreach took 5.9800148010254 microseconds<br />
Output for 5.4.32
Merging took 5.4371356964111 microseconds<br /> Foreach took 6.7160129547119 microseconds<br />
Output for 5.4.31
Merging took 4.7221183776855 microseconds<br /> Foreach took 5.8460235595703 microseconds<br />
Output for 5.4.30
Merging took 4.9920082092285 microseconds<br /> Foreach took 6.0849189758301 microseconds<br />
Output for 5.4.29
Merging took 5.1701068878174 microseconds<br /> Foreach took 6.2980651855469 microseconds<br />
Output for 5.4.28
Merging took 3.931999206543 microseconds<br /> Foreach took 4.796028137207 microseconds<br />
Output for 5.4.27
Merging took 5.4488182067871 microseconds<br /> Foreach took 6.6449642181396 microseconds<br />
Output for 5.4.26
Merging took 5.0480365753174 microseconds<br /> Foreach took 6.1459541320801 microseconds<br />
Output for 5.4.25
Merging took 5.4659843444824 microseconds<br /> Foreach took 6.8840980529785 microseconds<br />
Output for 5.4.24
Merging took 4.8561096191406 microseconds<br /> Foreach took 5.7129859924316 microseconds<br />
Output for 5.4.23
Merging took 5.173921585083 microseconds<br /> Foreach took 7.1539878845215 microseconds<br />
Output for 5.4.22
Merging took 4.533052444458 microseconds<br /> Foreach took 5.4421424865723 microseconds<br />
Output for 5.4.21
Merging took 5.6040287017822 microseconds<br /> Foreach took 6.2880516052246 microseconds<br />
Output for 5.4.20
Merging took 4.6589374542236 microseconds<br /> Foreach took 5.742073059082 microseconds<br />
Output for 5.4.19
Merging took 4.8370361328125 microseconds<br /> Foreach took 5.8069229125977 microseconds<br />
Output for 5.4.18
Merging took 5.4590702056885 microseconds<br /> Foreach took 6.8240165710449 microseconds<br />
Output for 5.4.17
Merging took 4.2891502380371 microseconds<br /> Foreach took 5.1989555358887 microseconds<br />
Output for 5.4.16
Merging took 5.0840377807617 microseconds<br /> Foreach took 6.0839653015137 microseconds<br />
Output for 5.4.15
Merging took 5.4361820220947 microseconds<br /> Foreach took 6.6640377044678 microseconds<br />
Output for 5.4.14
Merging took 4.7109127044678 microseconds<br /> Foreach took 5.0170421600342 microseconds<br />
Output for 5.4.13
Merging took 4.3890476226807 microseconds<br /> Foreach took 6.105899810791 microseconds<br />
Output for 5.4.12
Merging took 4.7180652618408 microseconds<br /> Foreach took 5.6328773498535 microseconds<br />
Output for 5.4.11
Merging took 5.4731369018555 microseconds<br /> Foreach took 6.9549083709717 microseconds<br />
Output for 5.4.10
Merging took 4.4059753417969 microseconds<br /> Foreach took 5.1760673522949 microseconds<br />
Output for 5.4.9
Merging took 4.2779445648193 microseconds<br /> Foreach took 5.1579475402832 microseconds<br />
Output for 5.4.8
Merging took 5.6588649749756 microseconds<br /> Foreach took 7.1558952331543 microseconds<br />
Output for 5.4.7
Merging took 5.4831504821777 microseconds<br /> Foreach took 6.8948268890381 microseconds<br />
Output for 5.4.6
Merging took 5.730152130127 microseconds<br /> Foreach took 6.8469047546387 microseconds<br />
Output for 5.4.5
Merging took 5.2640438079834 microseconds<br /> Foreach took 6.4542293548584 microseconds<br />
Output for 5.4.4
Merging took 4.7471523284912 microseconds<br /> Foreach took 4.8110485076904 microseconds<br />
Output for 5.4.3
Merging took 5.3489208221436 microseconds<br /> Foreach took 6.8240165710449 microseconds<br />
Output for 5.4.2
Merging took 4.9340724945068 microseconds<br /> Foreach took 6.4301490783691 microseconds<br />
Output for 5.4.1
Merging took 4.7969818115234 microseconds<br /> Foreach took 5.997896194458 microseconds<br />
Output for 5.4.0
Merging took 4.8041343688965 microseconds<br /> Foreach took 5.8598518371582 microseconds<br />
Output for 5.3.29
Merging took 4.4848918914795 microseconds<br /> Foreach took 5.5379867553711 microseconds<br />
Output for 5.3.28
Merging took 4.9948692321777 microseconds<br /> Foreach took 5.9831142425537 microseconds<br />
Output for 5.3.27
Merging took 5.2790641784668 microseconds<br /> Foreach took 6.4599514007568 microseconds<br />
Output for 5.3.26
Merging took 4.4450759887695 microseconds<br /> Foreach took 5.2530765533447 microseconds<br />
Output for 5.3.25
Merging took 5.0349235534668 microseconds<br /> Foreach took 6.162166595459 microseconds<br />
Output for 5.3.24
Merging took 5.3219795227051 microseconds<br /> Foreach took 6.6959857940674 microseconds<br />
Output for 5.3.23
Merging took 4.3289661407471 microseconds<br /> Foreach took 4.539966583252 microseconds<br />
Output for 5.3.22
Merging took 5.1288604736328 microseconds<br /> Foreach took 6.2699317932129 microseconds<br />
Output for 5.3.21
Merging took 5.2080154418945 microseconds<br /> Foreach took 5.7690143585205 microseconds<br />
Output for 5.3.20
Merging took 4.9209594726562 microseconds<br /> Foreach took 5.7210922241211 microseconds<br />
Output for 5.3.19
Merging took 5.0609111785889 microseconds<br /> Foreach took 6.1829090118408 microseconds<br />
Output for 5.3.18
Merging took 4.7719478607178 microseconds<br /> Foreach took 6.3600540161133 microseconds<br />
Output for 5.3.17
Merging took 3.6108493804932 microseconds<br /> Foreach took 4.6541690826416 microseconds<br />
Output for 5.3.16
Merging took 4.9140453338623 microseconds<br /> Foreach took 6.1240196228027 microseconds<br />
Output for 5.3.15
Merging took 4.8670768737793 microseconds<br /> Foreach took 5.8610439300537 microseconds<br />
Output for 5.3.14
Merging took 3.6249160766602 microseconds<br /> Foreach took 4.763126373291 microseconds<br />
Output for 5.3.13
Merging took 5.2030086517334 microseconds<br /> Foreach took 6.5600872039795 microseconds<br />
Output for 5.3.12
Merging took 5.0170421600342 microseconds<br /> Foreach took 5.328893661499 microseconds<br />
Output for 5.3.11
Merging took 4.0910243988037 microseconds<br /> Foreach took 5.3279399871826 microseconds<br />
Output for 5.3.10
Merging took 4.6911239624023 microseconds<br /> Foreach took 6.0050487518311 microseconds<br />
Output for 5.3.9
Merging took 4.9469470977783 microseconds<br /> Foreach took 5.7830810546875 microseconds<br />
Output for 5.3.8
Merging took 4.6892166137695 microseconds<br /> Foreach took 6.4408779144287 microseconds<br />
Output for 5.3.7
Merging took 4.5690536499023 microseconds<br /> Foreach took 5.5069923400879 microseconds<br />
Output for 5.3.6
Merging took 4.7597885131836 microseconds<br /> Foreach took 5.9609413146973 microseconds<br />
Output for 5.3.5
Merging took 4.586935043335 microseconds<br /> Foreach took 6.0281753540039 microseconds<br />
Output for 5.3.4
Merging took 5.3231716156006 microseconds<br /> Foreach took 6.721019744873 microseconds<br />
Output for 5.3.3
Merging took 4.9679279327393 microseconds<br /> Foreach took 6.3509941101074 microseconds<br />
Output for 5.3.2
Merging took 5.5420398712158 microseconds<br /> Foreach took 6.8411827087402 microseconds<br />
Output for 5.3.1
Merging took 5.1019191741943 microseconds<br /> Foreach took 6.3600540161133 microseconds<br />
Output for 5.3.0
Merging took 2.3629665374756 microseconds<br /> Foreach took 6.911039352417 microseconds<br />
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STATIC in /in/DKI1c on line 25
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/DKI1c on line 18
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /in/DKI1c on line 18
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_ARRAY, expecting ')' in /in/DKI1c on line 18
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/DKI1c on line 18
Process exited with code 255.