3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(0); $amount = 10000; $start = microtime(true); $alreadyOutput = array(); $iterator = $amount; while ($iterator --) { $num = rand(0, $amount); if(in_array($num, $alreadyOutput)){ continue; } $alreadyOutput[] = $num; } echo "in_array: ".(microtime(true) - $start)."ms || "; unset($alreadyOutput); $alreadyOutput = array(); $start2 = microtime(true); $iterator = $amount; while ($iterator --) { $num = rand(0, $amount); if($alreadyOutput[$num]){ continue; } $alreadyOutput[$num] = true; } echo "by key: ".(microtime(true) - $start2)."ms";
based on Anq56
Output for 7.1.0
in_array: 0.050559997558594ms || by key: 0.0033879280090332ms
Output for 7.0.14
in_array: 0.048372983932495ms || by key: 0.0028631687164307ms
Output for 7.0.6
in_array: 0.049252033233643ms || by key: 0.0030479431152344ms
Output for 7.0.5
in_array: 0.047323942184448ms || by key: 0.002856969833374ms
Output for 7.0.4
in_array: 0.044426918029785ms || by key: 0.0026350021362305ms
Output for 7.0.3
in_array: 0.040420055389404ms || by key: 0.0026059150695801ms
Output for 7.0.2
in_array: 0.038810014724731ms || by key: 0.0020599365234375ms
Output for 7.0.1
in_array: 0.037075996398926ms || by key: 0.0025551319122314ms
Output for 7.0.0
in_array: 0.039882183074951ms || by key: 0.0026190280914307ms
Output for hhvm-3.12.0
in_array: 0.25555491447449ms || by key: 0.0025568008422852ms
Output for hhvm-3.10.0
in_array: 0.30846905708313ms || by key: 0.005220890045166ms
Output for 5.6.28
in_array: 0.42226099967957ms || by key: 0.0030620098114014ms
Output for 5.6.21
in_array: 0.41144800186157ms || by key: 0.0030891895294189ms
Output for 5.6.20
in_array: 0.4427170753479ms || by key: 0.0034370422363281ms
Output for 5.6.19
in_array: 0.43461394309998ms || by key: 0.0031669139862061ms
Output for 5.6.18
in_array: 0.44085788726807ms || by key: 0.0033800601959229ms
Output for 5.6.17
in_array: 0.43916797637939ms || by key: 0.0032289028167725ms
Output for 5.6.16
in_array: 0.42655110359192ms || by key: 0.0032451152801514ms
Output for 5.6.15
in_array: 0.43024897575378ms || by key: 0.0033068656921387ms
Output for 5.6.14
in_array: 0.53208708763123ms || by key: 0.0038349628448486ms
Output for 5.6.13
in_array: 0.43218612670898ms || by key: 0.0033981800079346ms
Output for 5.6.12
in_array: 0.41714096069336ms || by key: 0.0031571388244629ms
Output for 5.6.11
in_array: 0.4360978603363ms || by key: 0.0032219886779785ms
Output for 5.6.10
in_array: 0.43239498138428ms || by key: 0.0031750202178955ms
Output for 5.6.9
in_array: 0.44024205207825ms || by key: 0.003216028213501ms
Output for 5.6.8
in_array: 0.44333791732788ms || by key: 0.0032799243927002ms
Output for 5.5.35
in_array: 0.44155406951904ms || by key: 0.0035090446472168ms
Output for 5.5.34
in_array: 0.44737911224365ms || by key: 0.0032148361206055ms
Output for 5.5.33
in_array: 0.445631980896ms || by key: 0.0032680034637451ms
Output for 5.5.32
in_array: 0.42472815513611ms || by key: 0.0032849311828613ms
Output for 5.5.31
in_array: 0.50416803359985ms || by key: 0.0037951469421387ms
Output for 5.5.30
in_array: 0.41317009925842ms || by key: 0.0030899047851562ms
Output for 5.5.29
in_array: 0.42081999778748ms || by key: 0.0035769939422607ms
Output for 5.5.28
in_array: 0.45994710922241ms || by key: 0.0037930011749268ms
Output for 5.5.27
in_array: 0.43914389610291ms || by key: 0.0032899379730225ms
Output for 5.5.26
in_array: 0.44461798667908ms || by key: 0.0032341480255127ms
Output for 5.5.25
in_array: 0.44156503677368ms || by key: 0.0031089782714844ms
Output for 5.5.24
in_array: 0.44989800453186ms || by key: 0.0033159255981445ms
Output for 5.4.45
in_array: 0.69238901138306ms || by key: 0.0052850246429443ms
Output for 5.4.44
in_array: 1.2280170917511ms || by key: 0.0058050155639648ms
Output for 5.4.43
in_array: 0.91936492919922ms || by key: 0.0054309368133545ms
Output for 5.4.42
in_array: 0.69084501266479ms || by key: 0.0055360794067383ms
Output for 5.4.41
in_array: 0.87247800827026ms || by key: 0.0051429271697998ms
Output for 5.4.40
in_array: 0.49649405479431ms || by key: 0.0046000480651855ms
Output for 5.4.39
in_array: 0.53454613685608ms || by key: 0.017170190811157ms
Output for 5.4.38
in_array: 0.90439891815186ms || by key: 0.0073812007904053ms
Output for 5.4.37
in_array: 0.7805449962616ms || by key: 0.0048110485076904ms
Output for 5.4.36
in_array: 0.5995020866394ms || by key: 0.0049769878387451ms
Output for 5.4.35
in_array: 0.59502601623535ms || by key: 0.0053038597106934ms
Output for 5.4.34
in_array: 0.76801013946533ms || by key: 0.0045099258422852ms
Output for 5.4.32
in_array: 0.43928098678589ms || by key: 0.0036249160766602ms
Output for 5.4.31
in_array: 0.42408895492554ms || by key: 0.003648042678833ms
Output for 5.4.30
in_array: 0.45548605918884ms || by key: 0.0034470558166504ms
Output for 5.4.29
in_array: 0.43484497070312ms || by key: 0.0036301612854004ms
Output for 5.4.28
in_array: 0.45320916175842ms || by key: 0.0042350292205811ms
Output for 5.4.27
in_array: 0.41984415054321ms || by key: 0.0036101341247559ms
Output for 5.4.26
in_array: 0.42861986160278ms || by key: 0.0038509368896484ms
Output for 5.4.25
in_array: 0.42952108383179ms || by key: 0.0040149688720703ms
Output for 5.4.24
in_array: 0.41104412078857ms || by key: 0.0042059421539307ms
Output for 5.4.23
in_array: 0.43840599060059ms || by key: 0.0039172172546387ms
Output for 5.4.22
in_array: 0.41745686531067ms || by key: 0.0035700798034668ms
Output for 5.4.21
in_array: 0.44315886497498ms || by key: 0.004065990447998ms
Output for 5.4.20
in_array: 0.42814898490906ms || by key: 0.007094144821167ms
Output for 5.4.19
in_array: 0.4520411491394ms || by key: 0.003572940826416ms
Output for 5.4.18
in_array: 0.42153596878052ms || by key: 0.003572940826416ms
Output for 5.4.17
in_array: 0.43437314033508ms || by key: 0.0039467811584473ms
Output for 5.4.16
in_array: 0.43490600585938ms || by key: 0.0034999847412109ms
Output for 5.4.15
in_array: 0.44710803031921ms || by key: 0.0065748691558838ms
Output for 5.4.14
in_array: 0.42208194732666ms || by key: 0.0035948753356934ms
Output for 5.4.13
in_array: 0.42936110496521ms || by key: 0.0034680366516113ms
Output for 5.4.12
in_array: 0.42970395088196ms || by key: 0.0035848617553711ms
Output for 5.4.11
in_array: 0.4812319278717ms || by key: 0.0072247982025146ms
Output for 5.4.10
in_array: 0.43764305114746ms || by key: 0.0035700798034668ms
Output for 5.4.9
in_array: 0.4538722038269ms || by key: 0.0038790702819824ms
Output for 5.4.8
in_array: 0.4403350353241ms || by key: 0.0047998428344727ms
Output for 5.4.7
in_array: 0.44137001037598ms || by key: 0.0036609172821045ms
Output for 5.4.6
in_array: 0.43421316146851ms || by key: 0.0034339427947998ms
Output for 5.4.5
in_array: 0.47759819030762ms || by key: 0.0038988590240479ms
Output for 5.4.4
in_array: 0.43345594406128ms || by key: 0.0041971206665039ms
Output for 5.4.3
in_array: 0.44547390937805ms || by key: 0.0038189888000488ms
Output for 5.4.2
in_array: 0.43152904510498ms || by key: 0.003654956817627ms
Output for 5.4.1
in_array: 0.45173001289368ms || by key: 0.0037078857421875ms
Output for 5.4.0
in_array: 0.41482090950012ms || by key: 0.0038449764251709ms
Output for 5.3.29
in_array: 0.4160430431366ms || by key: 0.0038390159606934ms
Output for 5.3.28
in_array: 0.41502499580383ms || by key: 0.0043730735778809ms
Output for 5.3.27
in_array: 0.42335915565491ms || by key: 0.0040168762207031ms
Output for 5.3.26
in_array: 0.42787313461304ms || by key: 0.004227876663208ms
Output for 5.3.25
in_array: 0.42418694496155ms || by key: 0.0043489933013916ms
Output for 5.3.24
in_array: 0.41991090774536ms || by key: 0.0043098926544189ms
Output for 5.3.23
in_array: 0.42255806922913ms || by key: 0.0043890476226807ms
Output for 5.3.22
in_array: 0.45536398887634ms || by key: 0.0035531520843506ms
Output for 5.3.21
in_array: 0.43568706512451ms || by key: 0.0038149356842041ms
Output for 5.3.20
in_array: 0.43689703941345ms || by key: 0.0042099952697754ms
Output for 5.3.19
in_array: 0.43912196159363ms || by key: 0.0047750473022461ms
Output for 5.3.18
in_array: 0.44757986068726ms || by key: 0.0039279460906982ms
Output for 5.3.17
in_array: 0.43181300163269ms || by key: 0.0040898323059082ms
Output for 5.3.16
in_array: 0.47824811935425ms || by key: 0.003633975982666ms
Output for 5.3.15
in_array: 0.42635107040405ms || by key: 0.0038940906524658ms
Output for 5.3.14
in_array: 0.43172001838684ms || by key: 0.0038619041442871ms
Output for 5.3.13
in_array: 0.45848298072815ms || by key: 0.0038049221038818ms
Output for 5.3.12
in_array: 0.4565601348877ms || by key: 0.0035319328308105ms
Output for 5.3.11
in_array: 0.4359450340271ms || by key: 0.0034999847412109ms
Output for 5.3.10
in_array: 0.43867087364197ms || by key: 0.0036830902099609ms
Output for 5.3.9
in_array: 0.42163300514221ms || by key: 0.0048379898071289ms
Output for 5.3.8
in_array: 0.44894099235535ms || by key: 0.0038008689880371ms
Output for 5.3.7
in_array: 0.427001953125ms || by key: 0.0035691261291504ms
Output for 5.3.6
in_array: 0.41204810142517ms || by key: 0.0042557716369629ms
Output for 5.3.5
in_array: 0.4187490940094ms || by key: 0.0035741329193115ms
Output for 5.3.4
in_array: 0.41209006309509ms || by key: 0.0038201808929443ms
Output for 5.3.3
in_array: 0.42075395584106ms || by key: 0.0039389133453369ms
Output for 5.3.2
in_array: 0.44021701812744ms || by key: 0.0041000843048096ms
Output for 5.3.1
in_array: 0.417072057724ms || by key: 0.0039310455322266ms
Output for 5.3.0
in_array: 0.40445303916931ms || by key: 0.0035490989685059ms
Output for 5.2.17
in_array: 0.61652398109436ms || by key: 0.004058837890625ms
Output for 5.2.16
in_array: 0.64654994010925ms || by key: 0.0037531852722168ms
Output for 5.2.15
in_array: 0.64347791671753ms || by key: 0.0040929317474365ms
Output for 5.2.14
in_array: 0.61054491996765ms || by key: 0.0041401386260986ms
Output for 5.2.13
in_array: 0.64604187011719ms || by key: 0.0042488574981689ms
Output for 5.2.12
in_array: 0.63837313652039ms || by key: 0.0041038990020752ms
Output for 5.2.11
in_array: 0.64250206947327ms || by key: 0.0039510726928711ms
Output for 5.2.10
in_array: 0.63421082496643ms || by key: 0.0038299560546875ms
Output for 5.2.9
in_array: 0.68239498138428ms || by key: 0.0039138793945312ms
Output for 5.2.8
in_array: 0.69074702262878ms || by key: 0.0042750835418701ms
Output for 5.2.7
in_array: 0.66369819641113ms || by key: 0.0079941749572754ms
Output for 5.2.6
in_array: 0.63945198059082ms || by key: 0.0038561820983887ms
Output for 5.2.5
in_array: 0.63466286659241ms || by key: 0.0042030811309814ms
Output for 5.2.4
in_array: 0.63991689682007ms || by key: 0.0041530132293701ms
Output for 5.2.3
in_array: 0.66930913925171ms || by key: 0.004101037979126ms
Output for 5.2.2
in_array: 0.67104196548462ms || by key: 0.0041091442108154ms
Output for 5.2.1
in_array: 0.66641211509705ms || by key: 0.0041649341583252ms
Output for 5.2.0
in_array: 0.66428589820862ms || by key: 0.0038430690765381ms
Output for 5.1.6
in_array: 0.77476596832275ms || by key: 0.0039961338043213ms
Output for 5.1.5
in_array: 0.88528180122375ms || by key: 0.011019945144653ms
Output for 5.1.4
in_array: 1.194375038147ms || by key: 0.0041670799255371ms
Output for 5.1.3
in_array: 1.0556130409241ms || by key: 0.0047800540924072ms
Output for 5.1.2
in_array: 1.4437251091003ms || by key: 0.0044000148773193ms
Output for 5.1.1
in_array: 1.3124120235443ms || by key: 0.012456893920898ms
Output for 5.1.0
in_array: 1.2227668762207ms || by key: 0.0046489238739014ms
Output for 5.0.5
in_array: 1.030394077301ms || by key: 0.0075209140777588ms
Output for 5.0.4
in_array: 0.84065103530884ms || by key: 0.010935068130493ms
Output for 5.0.3
in_array: 0.80115699768066ms || by key: 0.020249843597412ms
Output for 5.0.2
in_array: 0.94297385215759ms || by key: 0.0074658393859863ms
Output for 5.0.1
in_array: 0.94615292549133ms || by key: 0.0075170993804932ms
Output for 5.0.0
in_array: 0.72773885726929ms || by key: 0.0071020126342773ms
Output for 4.4.9
in_array: -0.377731ms || by key: 0.007527ms
Output for 4.4.8
in_array: -0.379697ms || by key: 0.007543ms
Output for 4.4.7
in_array: 0.625422ms || by key: 0.0093540000000001ms
Output for 4.4.6
in_array: -0.369648ms || by key: 0.008612ms
Output for 4.4.5
in_array: -0.368587ms || by key: 0.007671ms
Output for 4.4.4
in_array: 0.719744ms || by key: 0.014232ms
Output for 4.4.3
in_array: -0.397183ms || by key: 0.008161ms
Output for 4.4.2
in_array: -0.366409ms || by key: 0.007655ms
Output for 4.4.1
in_array: 0.638295ms || by key: 0.007724ms
Output for 4.4.0
in_array: -0.386534ms || by key: 0.008203ms
Output for 4.3.11
in_array: -0.396291ms || by key: 0.007843ms
Output for 4.3.10
in_array: 0.629471ms || by key: 0.0076729999999999ms
Output for 4.3.9
in_array: -0.362814ms || by key: 0.007707ms
Output for 4.3.8
in_array: -0.368245ms || by key: 0.013428ms
Output for 4.3.7
in_array: 0.656554ms || by key: 0.008122ms
Output for 4.3.6
in_array: -0.36286ms || by key: 0.008754ms
Output for 4.3.5
in_array: -0.366565ms || by key: 0.007744ms
Output for 4.3.4
in_array: 0.680325ms || by key: 0.0081840000000001ms
Output for 4.3.3
in_array: -0.331714ms || by key: 0.007999ms
Output for 4.3.2
in_array: -0.320566ms || by key: 0.021816ms
Output for 4.3.1
in_array: 0.647995ms || by key: 0.029538ms
Output for 4.3.0
in_array: 0.36823ms || by key: 0.028734ms