3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(0); $results = array(); for($i = 0; $i < 1000; $i++) { $results[] = (object) rand(0, 100000); } $start = microtime(true); for($i = 0; $i < 1000; $i++) { $alreadyOutput = array(); foreach ($results as $result) { if(in_array($result->date, $alreadyOutput)){ continue; } $alreadyOutput[] = $result->date; } } echo "in_array: ".(microtime(true) - $start)."ms || "; $start2 = microtime(true); for($i = 0; $i < 1000; $i++) { $echoedArray = array(); foreach ($results as $result) { if ($echoedArray[$result->date]) { continue; } $echoedArray[$result->date] = true; } } echo "by key: ".(microtime(true) - $start2)."ms";
based on 4j9a6
Output for 7.1.0
in_array: 0.27302002906799ms || by key: 0.20409321784973ms
Output for 7.0.14
in_array: 0.38960886001587ms || by key: -0.20251488685608ms
Output for 7.0.6
in_array: 0.25850987434387ms || by key: 0.21674108505249ms
Output for 7.0.5
in_array: 0.22841000556946ms || by key: 0.2149498462677ms
Output for 7.0.4
in_array: 0.24451208114624ms || by key: 0.20965504646301ms
Output for 7.0.3
in_array: 0.23377704620361ms || by key: 0.2142961025238ms
Output for 7.0.2
in_array: 0.25528883934021ms || by key: 0.21878099441528ms
Output for 7.0.1
in_array: 0.2656090259552ms || by key: 0.22503709793091ms
Output for 7.0.0
in_array: 0.26033091545105ms || by key: 0.2271420955658ms
Output for hhvm-3.12.0
in_array: 0.17887401580811ms || by key: 0.1249840259552ms
Output for hhvm-3.10.0
in_array: 0.40387797355652ms || by key: 0.34799599647522ms
Output for 5.6.28
in_array: 0.23245000839233ms || by key: -0.22948694229126ms
Output for 5.6.21
in_array: 0.36763000488281ms || by key: 0.25742101669312ms
Output for 5.6.20
in_array: 0.36194801330566ms || by key: 0.24773502349854ms
Output for 5.6.19
in_array: 0.33243799209595ms || by key: 0.24803996086121ms
Output for 5.6.18
in_array: 0.34425401687622ms || by key: 0.25291299819946ms
Output for 5.6.17
in_array: 0.47602987289429ms || by key: 0.32497978210449ms
Output for 5.6.16
in_array: 0.36011600494385ms || by key: 0.24706721305847ms
Output for 5.6.15
in_array: 0.3461799621582ms || by key: 0.25527405738831ms
Output for 5.6.14
in_array: 0.33489394187927ms || by key: 0.24101400375366ms
Output for 5.6.13
in_array: 0.3617799282074ms || by key: 0.25138688087463ms
Output for 5.6.12
in_array: 0.33137917518616ms || by key: 0.24186015129089ms
Output for 5.6.11
in_array: 0.32707810401917ms || by key: 0.23785495758057ms
Output for 5.6.10
in_array: 0.34263491630554ms || by key: 0.24750304222107ms
Output for 5.6.9
in_array: 0.38757419586182ms || by key: 0.27606582641602ms
Output for 5.6.8
in_array: 0.36516189575195ms || by key: 0.25673198699951ms
Output for 5.5.35
in_array: 0.35618901252747ms || by key: 0.22987699508667ms
Output for 5.5.34
in_array: 0.37654995918274ms || by key: 0.26231384277344ms
Output for 5.5.33
in_array: 0.34875106811523ms || by key: 0.25140190124512ms
Output for 5.5.32
in_array: 0.41974115371704ms || by key: 0.27197909355164ms
Output for 5.5.31
in_array: 0.37340402603149ms || by key: 0.25893211364746ms
Output for 5.5.30
in_array: 0.34815502166748ms || by key: 0.24536991119385ms
Output for 5.5.29
in_array: 0.35690021514893ms || by key: 0.25648593902588ms
Output for 5.5.28
in_array: 0.3721079826355ms || by key: 0.25910401344299ms
Output for 5.5.27
in_array: 0.37907695770264ms || by key: 0.25991487503052ms
Output for 5.5.26
in_array: 0.36017918586731ms || by key: 0.25467586517334ms
Output for 5.5.25
in_array: 0.39382791519165ms || by key: 0.26037001609802ms
Output for 5.5.24
in_array: 0.38001799583435ms || by key: 0.25598907470703ms
Output for 5.4.45
in_array: 0.34042692184448ms || by key: 0.23993110656738ms
Output for 5.4.44
in_array: 0.40806794166565ms || by key: 0.2386269569397ms
Output for 5.4.43
in_array: 0.34323906898499ms || by key: 0.24206495285034ms
Output for 5.4.42
in_array: 0.3671019077301ms || by key: 0.28741097450256ms
Output for 5.4.41
in_array: 0.33544087409973ms || by key: 0.24377799034119ms
Output for 5.4.40
in_array: 0.35293197631836ms || by key: 0.25502610206604ms
Output for 5.4.39
in_array: 0.40928077697754ms || by key: 0.28091597557068ms
Output for 5.4.38
in_array: 0.34129881858826ms || by key: 0.24874997138977ms
Output for 5.4.37
in_array: 0.42606091499329ms || by key: 0.27269911766052ms
Output for 5.4.36
in_array: 0.34415006637573ms || by key: 0.24657011032104ms
Output for 5.4.35
in_array: 0.33803105354309ms || by key: 0.23669719696045ms
Output for 5.4.34
in_array: 0.34014892578125ms || by key: 0.24011397361755ms
Output for 5.4.32
in_array: 0.38110399246216ms || by key: 0.27285504341125ms
Output for 5.4.31
in_array: 0.34634900093079ms || by key: 0.24821782112122ms
Output for 5.4.30
in_array: 0.32888913154602ms || by key: 0.23732614517212ms
Output for 5.4.29
in_array: 0.39366006851196ms || by key: 0.28382396697998ms
Output for 5.4.28
in_array: 0.3244149684906ms || by key: 0.23891592025757ms
Output for 5.4.27
in_array: 0.33108115196228ms || by key: 0.24161100387573ms
Output for 5.4.26
in_array: 0.38396191596985ms || by key: 0.27131509780884ms
Output for 5.4.25
in_array: 0.33749985694885ms || by key: 0.24170398712158ms
Output for 5.4.24
in_array: 0.38134479522705ms || by key: 0.24164199829102ms
Output for 5.4.23
in_array: 0.39159393310547ms || by key: 0.28357100486755ms
Output for 5.4.22
in_array: 0.39592099189758ms || by key: 0.28353714942932ms
Output for 5.4.21
in_array: 0.33906602859497ms || by key: 0.25132703781128ms
Output for 5.4.20
in_array: 0.35454392433167ms || by key: 0.25881481170654ms
Output for 5.4.19
in_array: 0.33774399757385ms || by key: 0.23971009254456ms
Output for 5.4.18
in_array: 0.34945893287659ms || by key: 0.24878787994385ms
Output for 5.4.17
in_array: 0.33381199836731ms || by key: 0.24260807037354ms
Output for 5.4.16
in_array: 0.32993292808533ms || by key: 0.24023294448853ms
Output for 5.4.15
in_array: 0.39991807937622ms || by key: 0.28179097175598ms
Output for 5.4.14
in_array: 0.40401101112366ms || by key: 0.24427103996277ms
Output for 5.4.13
in_array: 0.40292310714722ms || by key: 0.28365087509155ms
Output for 5.4.12
in_array: 0.34530091285706ms || by key: 0.2493109703064ms
Output for 5.4.11
in_array: 0.34659290313721ms || by key: 0.24950098991394ms
Output for 5.4.10
in_array: 0.3399829864502ms || by key: 0.24985980987549ms
Output for 5.4.9
in_array: 0.3355700969696ms || by key: 0.24728393554688ms
Output for 5.4.8
in_array: 0.34481811523438ms || by key: 0.25042104721069ms
Output for 5.4.7
in_array: 0.34355711936951ms || by key: 0.25134587287903ms
Output for 5.4.6
in_array: 0.33141994476318ms || by key: 0.24390602111816ms
Output for 5.4.5
in_array: 0.32742381095886ms || by key: 0.23609495162964ms
Output for 5.4.4
in_array: 0.33973288536072ms || by key: 0.24976682662964ms
Output for 5.4.3
in_array: 0.34488201141357ms || by key: 0.24282193183899ms
Output for 5.4.2
in_array: 0.35003590583801ms || by key: 0.25640988349915ms
Output for 5.4.1
in_array: 0.38528990745544ms || by key: 0.28523206710815ms
Output for 5.4.0
in_array: 0.32405495643616ms || by key: 0.23790907859802ms
Output for 5.3.29
in_array: 0.36955404281616ms || by key: 0.26874303817749ms
Output for 5.3.28
in_array: 0.38003301620483ms || by key: 0.27271699905396ms
Output for 5.3.27
in_array: 0.38063406944275ms || by key: 0.27432823181152ms
Output for 5.3.26
in_array: 0.3779149055481ms || by key: 0.27245903015137ms
Output for 5.3.25
in_array: 0.47505807876587ms || by key: 0.30807304382324ms
Output for 5.3.24
in_array: 0.37261819839478ms || by key: 0.26948308944702ms
Output for 5.3.23
in_array: 0.38106513023376ms || by key: 0.26843810081482ms
Output for 5.3.22
in_array: 0.40283608436584ms || by key: 0.29881286621094ms
Output for 5.3.21
in_array: 0.41286897659302ms || by key: 0.27854514122009ms
Output for 5.3.20
in_array: 0.42915892601013ms || by key: 0.30555105209351ms
Output for 5.3.19
in_array: 0.41687297821045ms || by key: 0.27475595474243ms
Output for 5.3.18
in_array: 0.40705418586731ms || by key: 0.27317404747009ms
Output for 5.3.17
in_array: 0.36873888969421ms || by key: 0.31612300872803ms
Output for 5.3.16
in_array: 0.39766693115234ms || by key: 0.27128481864929ms
Output for 5.3.15
in_array: 0.39486885070801ms || by key: 0.2702169418335ms
Output for 5.3.14
in_array: 0.40860199928284ms || by key: 0.28756403923035ms
Output for 5.3.13
in_array: 0.3729190826416ms || by key: 0.27109813690186ms
Output for 5.3.12
in_array: 0.36161804199219ms || by key: 0.26518988609314ms
Output for 5.3.11
in_array: 0.40952897071838ms || by key: 0.26822805404663ms
Output for 5.3.10
in_array: 0.36445212364197ms || by key: 0.26702380180359ms
Output for 5.3.9
in_array: 0.37381291389465ms || by key: 0.27757382392883ms
Output for 5.3.8
in_array: 0.3630039691925ms || by key: 0.26906108856201ms
Output for 5.3.7
in_array: 0.37674498558044ms || by key: 0.26681303977966ms
Output for 5.3.6
in_array: 0.36761903762817ms || by key: 0.26971483230591ms
Output for 5.3.5
in_array: 0.42333579063416ms || by key: 0.30562520027161ms
Output for 5.3.4
in_array: 0.49438190460205ms || by key: 0.27839303016663ms
Output for 5.3.3
in_array: 0.3780210018158ms || by key: 0.27112293243408ms
Output for 5.3.2
in_array: 0.35347509384155ms || by key: 0.26409792900085ms
Output for 5.3.1
in_array: 0.38047504425049ms || by key: 0.27651596069336ms
Output for 5.3.0
in_array: 0.41038084030151ms || by key: 0.30206108093262ms
Output for 5.2.17
in_array: 0.38067507743835ms || by key: 0.28617787361145ms
Output for 5.2.16
in_array: 0.38388586044312ms || by key: 0.28354501724243ms
Output for 5.2.15
in_array: 0.43898487091064ms || by key: 0.3664710521698ms
Output for 5.2.14
in_array: 0.36922907829285ms || by key: 0.27949905395508ms
Output for 5.2.13
in_array: 0.3849790096283ms || by key: 0.29283285140991ms
Output for 5.2.12
in_array: 0.44078707695007ms || by key: 0.32858204841614ms
Output for 5.2.11
in_array: 0.41803598403931ms || by key: 0.31507706642151ms
Output for 5.2.10
in_array: 0.37905311584473ms || by key: 0.28571486473083ms
Output for 5.2.9
in_array: 0.37830710411072ms || by key: 0.2860119342804ms
Output for 5.2.8
in_array: 0.38405299186707ms || by key: 0.29227089881897ms
Output for 5.2.7
in_array: 0.37194085121155ms || by key: 0.28940296173096ms
Output for 5.2.6
in_array: 0.38255405426025ms || by key: 0.30177783966064ms
Output for 5.2.5
in_array: 0.45751118659973ms || by key: 0.32617878913879ms
Output for 5.2.4
in_array: 0.39599704742432ms || by key: 0.29002714157104ms
Output for 5.2.3
in_array: 0.38718605041504ms || by key: 0.28912401199341ms
Output for 5.2.2
in_array: 0.36870288848877ms || by key: 0.29123497009277ms
Output for 5.2.1
in_array: 0.37930607795715ms || by key: 0.28517293930054ms
Output for 5.2.0
in_array: 0.36792302131653ms || by key: 0.27912592887878ms
Output for 5.1.6
in_array: 0.35437893867493ms || by key: 0.27780914306641ms
Output for 5.1.5
in_array: 0.35873413085938ms || by key: 0.2840940952301ms
Output for 5.1.4
in_array: 0.36809301376343ms || by key: 0.28479814529419ms
Output for 5.1.3
in_array: 0.36563491821289ms || by key: 0.28758788108826ms
Output for 5.1.2
in_array: 0.38175201416016ms || by key: 0.27849006652832ms
Output for 5.1.1
in_array: 0.36341905593872ms || by key: 0.28759407997131ms
Output for 5.1.0
in_array: 0.36673307418823ms || by key: 0.28183794021606ms
Output for 5.0.5
in_array: 0.59914207458496ms || by key: 0.46878790855408ms
Output for 5.0.4
in_array: 0.57129883766174ms || by key: 0.45863103866577ms
Output for 5.0.3
in_array: 0.54657816886902ms || by key: 0.45046496391296ms
Output for 5.0.2
in_array: 0.78755712509155ms || by key: 0.62386417388916ms
Output for 5.0.1
in_array: 0.54417991638184ms || by key: 0.45215797424316ms
Output for 5.0.0
in_array: 0.56155014038086ms || by key: 0.45347714424133ms
Output for 4.4.9
in_array: -0.505273ms || by key: 0.382214ms
Output for 4.4.8
in_array: -0.508206ms || by key: 0.381521ms
Output for 4.4.7
in_array: -0.431797ms || by key: 0.446549ms
Output for 4.4.6
in_array: -0.512866ms || by key: 0.375268ms
Output for 4.4.5
in_array: -0.522425ms || by key: 0.371319ms
Output for 4.4.4
in_array: 0.585953ms || by key: -0.562225ms
Output for 4.4.3
in_array: 0.496696ms || by key: -0.607382ms
Output for 4.4.2
in_array: -0.464095ms || by key: 0.390884ms
Output for 4.4.1
in_array: -0.467912ms || by key: 0.421663ms
Output for 4.4.0
in_array: -0.504798ms || by key: 0.391389ms
Output for 4.3.11
in_array: -0.494198ms || by key: 0.41327ms
Output for 4.3.10
in_array: 0.55945ms || by key: -0.54272ms
Output for 4.3.9
in_array: 0.567401ms || by key: -0.493995ms
Output for 4.3.8
in_array: 0.642928ms || by key: -0.456128ms
Output for 4.3.7
in_array: -0.361703ms || by key: 0.517589ms
Output for 4.3.6
in_array: -0.4239ms || by key: 0.468017ms
Output for 4.3.5
in_array: 0.556695ms || by key: -0.54414ms
Output for 4.3.4
in_array: -0.362708ms || by key: 0.515309ms
Output for 4.3.3
in_array: -0.43029ms || by key: 0.453799ms
Output for 4.3.2
in_array: 0.591856ms || by key: -0.539017ms
Output for 4.3.1
in_array: 0.58301ms || by key: -0.540165ms
Output for 4.3.0
in_array: -0.422944ms || by key: 0.458678ms