3v4l.org

run code in 300+ PHP versions simultaneously
<?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); $startTimeForeach = microtime(true); foreach ($classmap2 as $k => $v) { $classmap1[$k] = $v; } $endTimeForeach = microtime(true); function amerge(array $a, array $b, $performance = false) { foreach ($b as $key => $value) { if ($performance == false || 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); amerge($classmap1, $classmap2, true); $endTimeFunc = microtime(true); echo "Merging took " . (($endTimeMerge - $startTimeMerge)*1000) ." microseconds<br />\n"; echo "Foreach took " . (($endTimeForeach - $startTimeForeach)*1000) ." microseconds<br />\n"; echo "Func took " . (($endTimeFunc - $startTimeFunc)*1000) ." microseconds<br />\n";
Output for 5.6.21
Merging took 2.575159072876 microseconds<br /> Foreach took 2.5379657745361 microseconds<br /> Func took 8.6979866027832 microseconds<br />
Output for 5.6.20
Merging took 2.1579265594482 microseconds<br /> Foreach took 2.1579265594482 microseconds<br /> Func took 7.1299076080322 microseconds<br />
Output for 5.6.19
Merging took 2.1209716796875 microseconds<br /> Foreach took 2.065896987915 microseconds<br /> Func took 7.1570873260498 microseconds<br />
Output for 5.6.18
Merging took 1.74880027771 microseconds<br /> Foreach took 1.7321109771729 microseconds<br /> Func took 5.9280395507812 microseconds<br />
Output for 5.6.17
Merging took 2.2439956665039 microseconds<br /> Foreach took 2.2549629211426 microseconds<br /> Func took 7.8589916229248 microseconds<br />
Output for 5.6.16
Merging took 1.5580654144287 microseconds<br /> Foreach took 1.5711784362793 microseconds<br /> Func took 6.0019493103027 microseconds<br />
Output for 5.6.15
Merging took 1.723051071167 microseconds<br /> Foreach took 1.6610622406006 microseconds<br /> Func took 5.7129859924316 microseconds<br />
Output for 5.6.14
Merging took 2.1579265594482 microseconds<br /> Foreach took 2.1040439605713 microseconds<br /> Func took 7.1840286254883 microseconds<br />
Output for 5.6.13
Merging took 2.5339126586914 microseconds<br /> Foreach took 2.3930072784424 microseconds<br /> Func took 8.1889629364014 microseconds<br />
Output for 5.6.12
Merging took 1.5649795532227 microseconds<br /> Foreach took 1.5599727630615 microseconds<br /> Func took 5.4831504821777 microseconds<br />
Output for 5.6.11
Merging took 2.5820732116699 microseconds<br /> Foreach took 2.5050640106201 microseconds<br /> Func took 8.1379413604736 microseconds<br />
Output for 5.6.10
Merging took 1.9779205322266 microseconds<br /> Foreach took 2.4280548095703 microseconds<br /> Func took 7.3990821838379 microseconds<br />
Output for 5.6.9
Merging took 2.3250579833984 microseconds<br /> Foreach took 2.2890567779541 microseconds<br /> Func took 7.3819160461426 microseconds<br />
Output for 5.6.8
Merging took 2.1541118621826 microseconds<br /> Foreach took 2.4359226226807 microseconds<br /> Func took 6.7720413208008 microseconds<br />
Output for 5.6.7
Merging took 2.4979114532471 microseconds<br /> Foreach took 2.4328231811523 microseconds<br /> Func took 7.1849822998047 microseconds<br />
Output for 5.5.35
Merging took 2.4218559265137 microseconds<br /> Foreach took 2.3508071899414 microseconds<br /> Func took 8.2499980926514 microseconds<br />
Output for 5.5.34
Merging took 3.4060478210449 microseconds<br /> Foreach took 3.2699108123779 microseconds<br /> Func took 10.829925537109 microseconds<br />
Output for 5.5.33
Merging took 1.8749237060547 microseconds<br /> Foreach took 1.8610954284668 microseconds<br /> Func took 6.4420700073242 microseconds<br />
Output for 5.5.32
Merging took 2.2299289703369 microseconds<br /> Foreach took 2.2521018981934 microseconds<br /> Func took 7.2188377380371 microseconds<br />
Output for 5.5.31
Merging took 2.1319389343262 microseconds<br /> Foreach took 2.126932144165 microseconds<br /> Func took 7.3351860046387 microseconds<br />
Output for 5.5.30
Merging took 2.5579929351807 microseconds<br /> Foreach took 2.6290416717529 microseconds<br /> Func took 9.0279579162598 microseconds<br />
Output for 5.5.29
Merging took 1.5599727630615 microseconds<br /> Foreach took 1.5878677368164 microseconds<br /> Func took 5.558967590332 microseconds<br />
Output for 5.5.28
Merging took 2.5119781494141 microseconds<br /> Foreach took 2.518892288208 microseconds<br /> Func took 8.6488723754883 microseconds<br />
Output for 5.5.27
Merging took 2.3889541625977 microseconds<br /> Foreach took 2.377986907959 microseconds<br /> Func took 8.3889961242676 microseconds<br />
Output for 5.5.26
Merging took 2.2189617156982 microseconds<br /> Foreach took 2.1638870239258 microseconds<br /> Func took 7.6429843902588 microseconds<br />
Output for 5.5.25
Merging took 1.5089511871338 microseconds<br /> Foreach took 1.582145690918 microseconds<br /> Func took 5.5139064788818 microseconds<br />
Output for 5.5.24
Merging took 2.6259422302246 microseconds<br /> Foreach took 2.8989315032959 microseconds<br /> Func took 9.8738670349121 microseconds<br />
Output for 5.4.45
Merging took 4.260778427124 microseconds<br /> Foreach took 1.8899440765381 microseconds<br /> Func took 6.8299770355225 microseconds<br />
Output for 5.4.44
Merging took 4.6079158782959 microseconds<br /> Foreach took 2.0911693572998 microseconds<br /> Func took 7.7519416809082 microseconds<br />
Output for 5.4.43
Merging took 4.601001739502 microseconds<br /> Foreach took 2.1030902862549 microseconds<br /> Func took 7.5278282165527 microseconds<br />
Output for 5.4.42
Merging took 4.5552253723145 microseconds<br /> Foreach took 2.4468898773193 microseconds<br /> Func took 7.3621273040771 microseconds<br />
Output for 5.4.41
Merging took 3.8180351257324 microseconds<br /> Foreach took 1.6918182373047 microseconds<br /> Func took 6.0629844665527 microseconds<br />
Output for 5.4.40
Merging took 4.0898323059082 microseconds<br /> Foreach took 1.9171237945557 microseconds<br /> Func took 6.7059993743896 microseconds<br />
Output for 5.4.39
Merging took 3.5369396209717 microseconds<br /> Foreach took 1.5408992767334 microseconds<br /> Func took 5.8081150054932 microseconds<br />
Output for 5.4.38
Merging took 4.4231414794922 microseconds<br /> Foreach took 1.9650459289551 microseconds<br /> Func took 7.282018661499 microseconds<br />
Output for 5.4.37
Merging took 3.6840438842773 microseconds<br /> Foreach took 1.6119480133057 microseconds<br /> Func took 6.0310363769531 microseconds<br />
Output for 5.4.36
Merging took 5.4728984832764 microseconds<br /> Foreach took 2.4650096893311 microseconds<br /> Func took 9.0229511260986 microseconds<br />
Output for 5.4.35
Merging took 4.2378902435303 microseconds<br /> Foreach took 1.884937286377 microseconds<br /> Func took 6.8988800048828 microseconds<br />
Output for 5.4.34
Merging took 5.803108215332 microseconds<br /> Foreach took 2.1288394927979 microseconds<br /> Func took 8.7718963623047 microseconds<br />
Output for 5.4.32
Merging took 3.6640167236328 microseconds<br /> Foreach took 1.5799999237061 microseconds<br /> Func took 5.9399604797363 microseconds<br />
Output for 5.4.31
Merging took 4.5740604400635 microseconds<br /> Foreach took 1.971960067749 microseconds<br /> Func took 7.2791576385498 microseconds<br />
Output for 5.4.30
Merging took 4.8608779907227 microseconds<br /> Foreach took 2.2430419921875 microseconds<br /> Func took 8.080005645752 microseconds<br />
Output for 5.4.29
Merging took 4.8539638519287 microseconds<br /> Foreach took 2.17604637146 microseconds<br /> Func took 7.9548358917236 microseconds<br />
Output for 5.4.28
Merging took 4.8558712005615 microseconds<br /> Foreach took 2.1979808807373 microseconds<br /> Func took 8.3291530609131 microseconds<br />
Output for 5.4.27
Merging took 5.5160522460938 microseconds<br /> Foreach took 3.0841827392578 microseconds<br /> Func took 8.552074432373 microseconds<br />
Output for 5.4.26
Merging took 5.141019821167 microseconds<br /> Foreach took 2.3541450500488 microseconds<br /> Func took 8.6159706115723 microseconds<br />
Output for 5.4.25
Merging took 5.2118301391602 microseconds<br /> Foreach took 2.5489330291748 microseconds<br /> Func took 8.1169605255127 microseconds<br />
Output for 5.4.24
Merging took 3.6721229553223 microseconds<br /> Foreach took 1.6350746154785 microseconds<br /> Func took 5.9459209442139 microseconds<br />
Output for 5.4.23
Merging took 4.6460628509521 microseconds<br /> Foreach took 2.051830291748 microseconds<br /> Func took 7.5569152832031 microseconds<br />
Output for 5.4.22
Merging took 3.6158561706543 microseconds<br /> Foreach took 1.5439987182617 microseconds<br /> Func took 5.9621334075928 microseconds<br />
Output for 5.4.21
Merging took 5.3272247314453 microseconds<br /> Foreach took 2.3159980773926 microseconds<br /> Func took 8.5580348968506 microseconds<br />
Output for 5.4.20
Merging took 5.4271221160889 microseconds<br /> Foreach took 2.4559497833252 microseconds<br /> Func took 8.7540149688721 microseconds<br />
Output for 5.4.19
Merging took 4.688024520874 microseconds<br /> Foreach took 2.0289421081543 microseconds<br /> Func took 7.7600479125977 microseconds<br />
Output for 5.4.18
Merging took 3.8671493530273 microseconds<br /> Foreach took 1.6241073608398 microseconds<br /> Func took 6.0799121856689 microseconds<br />
Output for 5.4.17
Merging took 5.1829814910889 microseconds<br /> Foreach took 2.2969245910645 microseconds<br /> Func took 8.497953414917 microseconds<br />
Output for 5.4.16
Merging took 3.70192527771 microseconds<br /> Foreach took 1.5661716461182 microseconds<br /> Func took 6.6850185394287 microseconds<br />
Output for 5.4.15
Merging took 4.4658184051514 microseconds<br /> Foreach took 2.0248889923096 microseconds<br /> Func took 7.3950290679932 microseconds<br />
Output for 5.4.14
Merging took 5.2859783172607 microseconds<br /> Foreach took 2.4189949035645 microseconds<br /> Func took 8.7320804595947 microseconds<br />
Output for 5.4.13
Merging took 5.4919719696045 microseconds<br /> Foreach took 2.4299621582031 microseconds<br /> Func took 8.9290142059326 microseconds<br />
Output for 5.4.12
Merging took 5.5229663848877 microseconds<br /> Foreach took 2.5560855865479 microseconds<br /> Func took 9.3250274658203 microseconds<br />
Output for 5.4.11
Merging took 5.4161548614502 microseconds<br /> Foreach took 2.4178028106689 microseconds<br /> Func took 8.7518692016602 microseconds<br />
Output for 5.4.10
Merging took 4.3420791625977 microseconds<br /> Foreach took 1.8839836120605 microseconds<br /> Func took 6.8130493164062 microseconds<br />
Output for 5.4.9
Merging took 5.2971839904785 microseconds<br /> Foreach took 2.302885055542 microseconds<br /> Func took 9.4809532165527 microseconds<br />
Output for 5.4.8
Merging took 5.0559043884277 microseconds<br /> Foreach took 1.9590854644775 microseconds<br /> Func took 7.2810649871826 microseconds<br />
Output for 5.4.7
Merging took 5.0570964813232 microseconds<br /> Foreach took 2.2718906402588 microseconds<br /> Func took 7.8270435333252 microseconds<br />
Output for 5.4.6
Merging took 4.3020248413086 microseconds<br /> Foreach took 1.9030570983887 microseconds<br /> Func took 7.0521831512451 microseconds<br />
Output for 5.4.5
Merging took 5.3880214691162 microseconds<br /> Foreach took 2.1791458129883 microseconds<br /> Func took 8.0521106719971 microseconds<br />
Output for 5.4.4
Merging took 5.3668022155762 microseconds<br /> Foreach took 2.1238327026367 microseconds<br /> Func took 8.1119537353516 microseconds<br />
Output for 5.4.3
Merging took 5.3560733795166 microseconds<br /> Foreach took 2.1560192108154 microseconds<br /> Func took 7.5869560241699 microseconds<br />
Output for 5.4.2
Merging took 4.4820308685303 microseconds<br /> Foreach took 1.9071102142334 microseconds<br /> Func took 7.0350170135498 microseconds<br />
Output for 5.4.1
Merging took 4.2850971221924 microseconds<br /> Foreach took 1.93190574646 microseconds<br /> Func took 7.0841312408447 microseconds<br />
Output for 5.4.0
Merging took 5.4581165313721 microseconds<br /> Foreach took 2.4349689483643 microseconds<br /> Func took 8.9280605316162 microseconds<br />
Output for 5.3.29
Merging took 5.2981376647949 microseconds<br /> Foreach took 2.4678707122803 microseconds<br /> Func took 9.0141296386719 microseconds<br />
Output for 5.3.28
Merging took 3.715991973877 microseconds<br /> Foreach took 1.7411708831787 microseconds<br /> Func took 6.5770149230957 microseconds<br />
Output for 5.3.27
Merging took 6.0281753540039 microseconds<br /> Foreach took 2.4988651275635 microseconds<br /> Func took 9.4339847564697 microseconds<br />
Output for 5.3.26
Merging took 5.0399303436279 microseconds<br /> Foreach took 2.3579597473145 microseconds<br /> Func took 8.6159706115723 microseconds<br />
Output for 5.3.25
Merging took 5.2659511566162 microseconds<br /> Foreach took 2.5110244750977 microseconds<br /> Func took 8.9709758758545 microseconds<br />
Output for 5.3.24
Merging took 3.9198398590088 microseconds<br /> Foreach took 1.8730163574219 microseconds<br /> Func took 6.9119930267334 microseconds<br />
Output for 5.3.23
Merging took 4.0500164031982 microseconds<br /> Foreach took 1.7900466918945 microseconds<br /> Func took 7.0018768310547 microseconds<br />
Output for 5.3.22
Merging took 4.9300193786621 microseconds<br /> Foreach took 2.3329257965088 microseconds<br /> Func took 8.8720321655273 microseconds<br />
Output for 5.3.21
Merging took 4.2178630828857 microseconds<br /> Foreach took 2.0320415496826 microseconds<br /> Func took 7.4591636657715 microseconds<br />
Output for 5.3.20
Merging took 5.2449703216553 microseconds<br /> Foreach took 2.4189949035645 microseconds<br /> Func took 8.9092254638672 microseconds<br />
Output for 5.3.19
Merging took 4.716157913208 microseconds<br /> Foreach took 2.2540092468262 microseconds<br /> Func took 10.53786277771 microseconds<br />
Output for 5.3.18
Merging took 5.18798828125 microseconds<br /> Foreach took 2.3348331451416 microseconds<br /> Func took 7.8518390655518 microseconds<br />
Output for 5.3.17
Merging took 5.2378177642822 microseconds<br /> Foreach took 2.5298595428467 microseconds<br /> Func took 8.9871883392334 microseconds<br />
Output for 5.3.16
Merging took 4.1048526763916 microseconds<br /> Foreach took 1.971960067749 microseconds<br /> Func took 7.0528984069824 microseconds<br />
Output for 5.3.15
Merging took 5.4240226745605 microseconds<br /> Foreach took 2.5291442871094 microseconds<br /> Func took 9.2170238494873 microseconds<br />
Output for 5.3.14
Merging took 3.5459995269775 microseconds<br /> Foreach took 1.6579627990723 microseconds<br /> Func took 6.3550472259521 microseconds<br />
Output for 5.3.13
Merging took 4.7261714935303 microseconds<br /> Foreach took 2.5150775909424 microseconds<br /> Func took 8.1570148468018 microseconds<br />
Output for 5.3.12
Merging took 4.1851997375488 microseconds<br /> Foreach took 2.0079612731934 microseconds<br /> Func took 7.6050758361816 microseconds<br />
Output for 5.3.11
Merging took 4.4291019439697 microseconds<br /> Foreach took 2.0320415496826 microseconds<br /> Func took 7.5180530548096 microseconds<br />
Output for 5.3.10
Merging took 5.1109790802002 microseconds<br /> Foreach took 2.5649070739746 microseconds<br /> Func took 8.969783782959 microseconds<br />
Output for 5.3.9
Merging took 5.314826965332 microseconds<br /> Foreach took 2.3491382598877 microseconds<br /> Func took 9.023904800415 microseconds<br />
Output for 5.3.8
Merging took 4.4600963592529 microseconds<br /> Foreach took 2.1369457244873 microseconds<br /> Func took 7.7829360961914 microseconds<br />
Output for 5.3.7
Merging took 4.7268867492676 microseconds<br /> Foreach took 2.2339820861816 microseconds<br /> Func took 8.1520080566406 microseconds<br />
Output for 5.3.6
Merging took 3.9029121398926 microseconds<br /> Foreach took 1.8868446350098 microseconds<br /> Func took 7.1151256561279 microseconds<br />
Output for 5.3.5
Merging took 3.5691261291504 microseconds<br /> Foreach took 1.6689300537109 microseconds<br /> Func took 6.1540603637695 microseconds<br />
Output for 5.3.4
Merging took 5.5480003356934 microseconds<br /> Foreach took 1.9769668579102 microseconds<br /> Func took 9.7758769989014 microseconds<br />
Output for 5.3.3
Merging took 3.4999847412109 microseconds<br /> Foreach took 1.5909671783447 microseconds<br /> Func took 6.1080455780029 microseconds<br />
Output for 5.3.2
Merging took 3.5488605499268 microseconds<br /> Foreach took 1.6319751739502 microseconds<br /> Func took 6.1111450195312 microseconds<br />
Output for 5.3.1
Merging took 4.7199726104736 microseconds<br /> Foreach took 2.3081302642822 microseconds<br /> Func took 8.3699226379395 microseconds<br />
Output for 5.3.0
Merging took 2.3961067199707 microseconds<br /> Foreach took 2.6829242706299 microseconds<br /> Func took 8.8729858398438 microseconds<br />
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_STATIC in /in/bc7Dk on line 34
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/bc7Dk on line 27
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /in/bc7Dk on line 27
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_ARRAY, expecting ')' in /in/bc7Dk on line 27
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/bc7Dk on line 27
Process exited with code 255.

preferences:
239.95 ms | 1386 KiB | 162 Q