3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = []; $b = []; // populate $a for ($i = 0;$i < 10000; $i++) { $a[$i] = ''; } // populate $b for ($i = 10000; $i < 20000; $i++) { $b[$i] = ''; } // intersection somewhere in the middle $intersect = rand(5000, 6000); $b[$intersect] = ''; $timer = microtime(); if (!empty(array_intersect_key($a, $b))) { var_dump('Method 1: INTERSECTION FOUND! Timer: ', microtime() - $timer); } $timer = microtime(); foreach ($a as $key => $val) { if (isset($b[$key])) { var_dump('Method 2: INTERSECTION FOUND! Timer: ', microtime() - $timer); break; } }
Output for 7.2.0
Notice: A non well formed numeric value encountered in /in/Smj1l on line 21 Notice: A non well formed numeric value encountered in /in/Smj1l on line 21 string(37) "Method 1: INTERSECTION FOUND! Timer: " float(5.4E-5) Notice: A non well formed numeric value encountered in /in/Smj1l on line 27 Notice: A non well formed numeric value encountered in /in/Smj1l on line 27 string(37) "Method 2: INTERSECTION FOUND! Timer: " float(9.2E-5)
Output for 7.1.7
Notice: A non well formed numeric value encountered in /in/Smj1l on line 21 Notice: A non well formed numeric value encountered in /in/Smj1l on line 21 string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000111) Notice: A non well formed numeric value encountered in /in/Smj1l on line 27 Notice: A non well formed numeric value encountered in /in/Smj1l on line 27 string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000173)
Output for 7.1.6
Notice: A non well formed numeric value encountered in /in/Smj1l on line 21 Notice: A non well formed numeric value encountered in /in/Smj1l on line 21 string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000146) Notice: A non well formed numeric value encountered in /in/Smj1l on line 27 Notice: A non well formed numeric value encountered in /in/Smj1l on line 27 string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000217)
Output for 7.1.5
Notice: A non well formed numeric value encountered in /in/Smj1l on line 21 Notice: A non well formed numeric value encountered in /in/Smj1l on line 21 string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000138) Notice: A non well formed numeric value encountered in /in/Smj1l on line 27 Notice: A non well formed numeric value encountered in /in/Smj1l on line 27 string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000276)
Output for 7.1.0
Notice: A non well formed numeric value encountered in /in/Smj1l on line 21 Notice: A non well formed numeric value encountered in /in/Smj1l on line 21 string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000103) Notice: A non well formed numeric value encountered in /in/Smj1l on line 27 Notice: A non well formed numeric value encountered in /in/Smj1l on line 27 string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.00018)
Output for 7.0.20
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.00010300000000001) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000162)
Output for 7.0.10
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(5.9E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(9.0E-5)
Output for 7.0.9
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(5.4999999999999E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000102)
Output for 7.0.8
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(5.2E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000108)
Output for 7.0.7
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(6.0E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(9.9E-5)
Output for 7.0.6
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(6.7999999999999E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000117)
Output for 7.0.5
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(9.0999999999999E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000159)
Output for 7.0.4
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(5.7E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(8.0E-5)
Output for 7.0.3
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(6.3E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(9.6E-5)
Output for 7.0.2
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(5.5E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(8.8E-5)
Output for 7.0.1
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(8.6E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.00015)
Output for 7.0.0
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(6.2E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(8.9E-5)
Output for 5.6.28
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000112) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000381)
Output for 5.6.25
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000127) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000311)
Output for 5.6.24
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(7.5E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000348)
Output for 5.6.23
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(8.5999999999999E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000394)
Output for 5.6.22
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000115) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000236)
Output for 5.6.21
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000128) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000241)
Output for 5.6.20
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000191) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000233)
Output for 5.6.19
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000141) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000232)
Output for 5.6.18
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(6.7E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000222)
Output for 5.6.17
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000144) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000223)
Output for 5.6.16
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.00014) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.00023)
Output for 5.6.15
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000148) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000244)
Output for 5.6.14
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000145) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000268)
Output for 5.6.13
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000136) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000233)
Output for 5.6.12
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000135) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000225)
Output for 5.6.11
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000155) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000238)
Output for 5.6.10
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000153) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000226)
Output for 5.6.9
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(7.0E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000225)
Output for 5.6.8
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(6.2E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000188)
Output for 5.6.7
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000137) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000274)
Output for 5.6.6
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000166) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000366)
Output for 5.6.5
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000165) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000284)
Output for 5.6.4
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000198) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000291)
Output for 5.6.3
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.00025) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000372)
Output for 5.6.2
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000177) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.00028)
Output for 5.6.1
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000215) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000368)
Output for 5.6.0
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000208) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000359)
Output for 5.5.38
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(8.0999999999999E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000288)
Output for 5.5.37
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(7.9E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000236)
Output for 5.5.36
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000156) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000542)
Output for 5.5.35
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(8.2E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000474)
Output for 5.5.34
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.00017) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000288)
Output for 5.5.33
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(6.7999999999999E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000219)
Output for 5.5.32
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000167) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000267)
Output for 5.5.31
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(6.8E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000248)
Output for 5.5.30
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(6.8E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.00023)
Output for 5.5.29
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.00011) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.00029)
Output for 5.5.28
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(6.2E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000177)
Output for 5.5.27
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000142) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000254)
Output for 5.5.26
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000216) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000382)
Output for 5.5.25
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000126) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000364)
Output for 5.5.24
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.00015) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000244)
Output for 5.5.23
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(6.8E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000215)
Output for 5.5.22
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(6.6E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000227)
Output for 5.5.21
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(8.3000000000001E-5) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000306)
Output for 5.5.20
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000133) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000224)
Output for 5.5.19
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000228) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000387)
Output for 5.5.18
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000208) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.00034)
Output for 5.5.16
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.00031) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.00057)
Output for 5.5.15
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000224) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000414)
Output for 5.5.14
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000143) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.00052)
Output for 5.5.13
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000193) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000338)
Output for 5.5.12
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000208) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000394)
Output for 5.5.11
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.00013) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000385)
Output for 5.5.10
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000106) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000411)
Output for 5.5.9
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000156) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000249)
Output for 5.5.8
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000214) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000322)
Output for 5.5.7
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.00012) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000315)
Output for 5.5.6
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000108) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000268)
Output for 5.5.5
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000144) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.0004)
Output for 5.5.4
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000159) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000217)
Output for 5.5.3
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000146) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000412)
Output for 5.5.2
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000136) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.00039)
Output for 5.5.1
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000218) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000379)
Output for 5.5.0
string(37) "Method 1: INTERSECTION FOUND! Timer: " float(0.000125) string(37) "Method 2: INTERSECTION FOUND! Timer: " float(0.000307)

preferences:
60.9 ms | 401 KiB | 87 Q