3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $classmap1 = array(); for ($i=1; $i<=10; $i++) { $classmap1['a'.$i] = $i+1; } $classmap2 = array(); for ($i=1; $i<=10; $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); echo "Merging took " . ($endTimeMerge - $startTimeMerge) ." seconds<br />\n"; echo "Foreach took " . ($endTimeMerge - $startTimeMerge) ." seconds<br />\n";
Output for 7.0.0 - 7.0.2, 7.0.4, 7.1.0
Merging took 1.9073486328125E-6 seconds<br /> Foreach took 1.9073486328125E-6 seconds<br />
Output for 7.0.5, 7.0.14
Merging took 2.1457672119141E-6 seconds<br /> Foreach took 2.1457672119141E-6 seconds<br />
Output for 7.0.7
Merging took 2.8610229492188E-6 seconds<br /> Foreach took 2.8610229492188E-6 seconds<br />
Output for 7.0.6
Merging took 9.5367431640625E-7 seconds<br /> Foreach took 9.5367431640625E-7 seconds<br />
Output for 7.0.3
Merging took 1.1920928955078E-6 seconds<br /> Foreach took 1.1920928955078E-6 seconds<br />
Output for 5.5.6, 5.5.8 - 5.5.9, 5.5.12 - 5.5.15, 5.5.19 - 5.5.23, 5.5.25 - 5.5.27, 5.5.29 - 5.5.30, 5.5.32 - 5.5.33, 5.6.0, 5.6.2 - 5.6.3, 5.6.6 - 5.6.7, 5.6.9 - 5.6.10, 5.6.12, 5.6.18 - 5.6.21, 5.6.28
Merging took 5.0067901611328E-6 seconds<br /> Foreach took 5.0067901611328E-6 seconds<br />
Output for 5.5.11, 5.5.16 - 5.5.18, 5.5.34, 5.5.36, 5.6.1, 5.6.4, 5.6.8, 5.6.11, 5.6.13 - 5.6.15, 5.6.17, 5.6.22
Merging took 4.0531158447266E-6 seconds<br /> Foreach took 4.0531158447266E-6 seconds<br />
Output for 5.3.5, 5.4.42, 5.5.7, 5.5.24, 5.5.28, 5.6.16
Merging took 5.9604644775391E-6 seconds<br /> Foreach took 5.9604644775391E-6 seconds<br />
Output for 5.6.5
Merging took 3.814697265625E-6 seconds<br /> Foreach took 3.814697265625E-6 seconds<br />
Output for 5.2.2, 5.2.7 - 5.2.8, 5.3.8, 5.4.8 - 5.4.9, 5.4.40, 5.5.35
Merging took 1.0967254638672E-5 seconds<br /> Foreach took 1.0967254638672E-5 seconds<br />
Output for 5.5.31
Merging took 3.0994415283203E-6 seconds<br /> Foreach took 3.0994415283203E-6 seconds<br />
Output for 5.5.10
Merging took 4.7683715820312E-6 seconds<br /> Foreach took 4.7683715820312E-6 seconds<br />
Output for 5.3.15, 5.3.24, 5.4.0, 5.4.3, 5.4.16, 5.4.18, 5.5.5
Merging took 6.9141387939453E-6 seconds<br /> Foreach took 6.9141387939453E-6 seconds<br />
Output for 5.5.4
Merging took 1.3828277587891E-5 seconds<br /> Foreach took 1.3828277587891E-5 seconds<br />
Output for 5.2.12 - 5.2.14, 5.3.1, 5.3.16, 5.3.18, 5.3.21, 5.3.23, 5.3.25, 5.3.28, 5.4.21, 5.4.23, 5.4.26 - 5.4.27, 5.4.29, 5.4.34, 5.4.36 - 5.4.37, 5.4.41, 5.4.44, 5.5.3
Merging took 9.0599060058594E-6 seconds<br /> Foreach took 9.0599060058594E-6 seconds<br />
Output for 5.2.10, 5.2.16, 5.3.3, 5.3.10, 5.4.4, 5.4.6, 5.4.12, 5.4.32, 5.5.0, 5.5.2
Merging took 1.0013580322266E-5 seconds<br /> Foreach took 1.0013580322266E-5 seconds<br />
Output for 5.2.11, 5.3.19 - 5.3.20, 5.4.10, 5.4.13 - 5.4.14, 5.4.30 - 5.4.31, 5.4.45, 5.5.1
Merging took 8.8214874267578E-6 seconds<br /> Foreach took 8.8214874267578E-6 seconds<br />
Output for 5.3.4, 5.3.9, 5.3.11 - 5.3.12, 5.3.26, 5.3.29, 5.4.28, 5.4.35, 5.4.43
Merging took 7.8678131103516E-6 seconds<br /> Foreach took 7.8678131103516E-6 seconds<br />
Output for 5.3.0, 5.3.2, 5.3.6 - 5.3.7, 5.3.13 - 5.3.14, 5.4.2, 5.4.11, 5.4.17, 5.4.19 - 5.4.20, 5.4.24 - 5.4.25, 5.4.39
Merging took 8.1062316894531E-6 seconds<br /> Foreach took 8.1062316894531E-6 seconds<br />
Output for 5.4.38
Merging took 1.8835067749023E-5 seconds<br /> Foreach took 1.8835067749023E-5 seconds<br />
Output for 5.2.15, 5.2.17, 5.4.22
Merging took 7.1525573730469E-6 seconds<br /> Foreach took 7.1525573730469E-6 seconds<br />
Output for 5.4.7, 5.4.15
Merging took 1.1920928955078E-5 seconds<br /> Foreach took 1.1920928955078E-5 seconds<br />
Output for 5.2.6, 5.4.5
Merging took 1.215934753418E-5 seconds<br /> Foreach took 1.215934753418E-5 seconds<br />
Output for 5.4.1
Merging took 1.5974044799805E-5 seconds<br /> Foreach took 1.5974044799805E-5 seconds<br />
Output for 5.2.4, 5.3.22, 5.3.27
Merging took 1.4066696166992E-5 seconds<br /> Foreach took 1.4066696166992E-5 seconds<br />
Output for 5.3.17
Merging took 1.7881393432617E-5 seconds<br /> Foreach took 1.7881393432617E-5 seconds<br />
Output for 5.2.9
Merging took 1.6927719116211E-5 seconds<br /> Foreach took 1.6927719116211E-5 seconds<br />
Output for 5.2.5
Merging took 2.0027160644531E-5 seconds<br /> Foreach took 2.0027160644531E-5 seconds<br />
Output for 5.2.3
Merging took 1.3113021850586E-5 seconds<br /> Foreach took 1.3113021850586E-5 seconds<br />
Output for 5.2.1
Merging took 9.0599060058594E-06 seconds<br /> Foreach took 9.0599060058594E-06 seconds<br />
Output for 5.2.0
Merging took 8.1062316894531E-06 seconds<br /> Foreach took 8.1062316894531E-06 seconds<br />
Output for 5.0.0, 5.1.5 - 5.1.6
Merging took 1.3113021850586E-05 seconds<br /> Foreach took 1.3113021850586E-05 seconds<br />
Output for 5.1.4
Merging took 1.4066696166992E-05 seconds<br /> Foreach took 1.4066696166992E-05 seconds<br />
Output for 5.1.3
Merging took 1.5020370483398E-05 seconds<br /> Foreach took 1.5020370483398E-05 seconds<br />
Output for 5.0.1, 5.0.4, 5.1.2
Merging took 1.215934753418E-05 seconds<br /> Foreach took 1.215934753418E-05 seconds<br />
Output for 5.1.1
Merging took 1.2874603271484E-05 seconds<br /> Foreach took 1.2874603271484E-05 seconds<br />
Output for 5.1.0
Merging took 3.6001205444336E-05 seconds<br /> Foreach took 3.6001205444336E-05 seconds<br />
Output for 5.0.5
Merging took 1.1920928955078E-05 seconds<br /> Foreach took 1.1920928955078E-05 seconds<br />
Output for 5.0.3
Merging took 9.7751617431641E-06 seconds<br /> Foreach took 9.7751617431641E-06 seconds<br />
Output for 5.0.2
Merging took 1.0013580322266E-05 seconds<br /> Foreach took 1.0013580322266E-05 seconds<br />
Output for 4.4.9
Merging took 2.9000000000001E-05 seconds<br /> Foreach took 2.9000000000001E-05 seconds<br />
Output for 4.3.10, 4.4.8
Merging took 1.6000000000016E-05 seconds<br /> Foreach took 1.6000000000016E-05 seconds<br />
Output for 4.4.7
Merging took 2.1000000000049E-05 seconds<br /> Foreach took 2.1000000000049E-05 seconds<br />
Output for 4.4.6
Merging took 2.2000000000001E-05 seconds<br /> Foreach took 2.2000000000001E-05 seconds<br />
Output for 4.4.5
Merging took 2.8E-05 seconds<br /> Foreach took 2.8E-05 seconds<br />
Output for 4.4.4
Merging took 1.4999999999987E-05 seconds<br /> Foreach took 1.4999999999987E-05 seconds<br />
Output for 4.3.1, 4.4.3
Merging took 2.000000000002E-05 seconds<br /> Foreach took 2.000000000002E-05 seconds<br />
Output for 4.4.2
Merging took 2.2999999999995E-05 seconds<br /> Foreach took 2.2999999999995E-05 seconds<br />
Output for 4.4.1
Merging took 2.3999999999968E-05 seconds<br /> Foreach took 2.3999999999968E-05 seconds<br />
Output for 4.4.0
Merging took 2.599999999997E-05 seconds<br /> Foreach took 2.599999999997E-05 seconds<br />
Output for 4.3.2, 4.3.6, 4.3.9, 4.3.11
Merging took 1.8999999999991E-05 seconds<br /> Foreach took 1.8999999999991E-05 seconds<br />
Output for 4.3.8
Merging took 1.2000000000012E-05 seconds<br /> Foreach took 1.2000000000012E-05 seconds<br />
Output for 4.3.7
Merging took 2.0999999999993E-05 seconds<br /> Foreach took 2.0999999999993E-05 seconds<br />
Output for 4.3.5
Merging took 1.7000000000045E-05 seconds<br /> Foreach took 1.7000000000045E-05 seconds<br />
Output for 4.3.3 - 4.3.4
Merging took 1.7999999999962E-05 seconds<br /> Foreach took 1.7999999999962E-05 seconds<br />
Output for 4.3.0
Merging took 1.9000000000005E-05 seconds<br /> Foreach took 1.9000000000005E-05 seconds<br />