3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(0); $results = array(); for($i = 0; $i < 3000; $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 kaHMN
Output for 7.1.0
in_array: -0.47996592521667ms || by key: 1.2532289028168ms
Output for 7.0.14
in_array: 1.062922000885ms || by key: 1.0356330871582ms
Output for 7.0.6
in_array: 0.7217710018158ms || by key: 0.63370203971863ms
Output for 7.0.5
in_array: 0.69839811325073ms || by key: 0.61275506019592ms
Output for 7.0.4
in_array: 0.69935607910156ms || by key: 0.60797882080078ms
Output for 7.0.3
in_array: 0.69840407371521ms || by key: 0.6195809841156ms
Output for 7.0.2
in_array: 0.69602584838867ms || by key: 0.62464904785156ms
Output for 7.0.1
in_array: 0.79707598686218ms || by key: 0.64728093147278ms
Output for 7.0.0
in_array: 0.7251889705658ms || by key: 0.64504218101501ms
Output for hhvm-3.12.0
in_array: 0.76879000663757ms || by key: 0.54416108131409ms
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.28
in_array: 0.65563607215881ms || by key: 1.033411026001ms
Output for 5.6.21
in_array: 1.0672039985657ms || by key: 0.73979115486145ms
Output for 5.6.20
in_array: 1.0450110435486ms || by key: 0.71343302726746ms
Output for 5.6.19
in_array: 1.0336630344391ms || by key: 0.79997301101685ms
Output for 5.6.18
in_array: 1.033942937851ms || by key: 0.73843693733215ms
Output for 5.6.17
in_array: 1.032478094101ms || by key: 0.8483419418335ms
Output for 5.6.16
in_array: 1.0125019550323ms || by key: 0.70706582069397ms
Output for 5.6.15
in_array: 1.0755240917206ms || by key: 0.74053907394409ms
Output for 5.6.14
in_array: 1.0412309169769ms || by key: 0.72668886184692ms
Output for 5.6.13
in_array: 1.0036020278931ms || by key: 0.72654581069946ms
Output for 5.6.12
in_array: 1.0421960353851ms || by key: 0.74198484420776ms
Output for 5.6.11
in_array: 1.1440088748932ms || by key: 0.78770804405212ms
Output for 5.6.10
in_array: 1.0253748893738ms || by key: 0.72952699661255ms
Output for 5.6.9
in_array: 1.0401530265808ms || by key: 0.72738099098206ms
Output for 5.6.8
in_array: 1.1016218662262ms || by key: 0.79713797569275ms
Output for 5.6.7
in_array: 0.93244695663452ms || by key: 0.60722780227661ms
Output for 5.5.35
in_array: 0.9183349609375ms || by key: 0.64043498039246ms
Output for 5.5.34
in_array: 1.0489511489868ms || by key: 0.74674391746521ms
Output for 5.5.33
in_array: 1.0365250110626ms || by key: 0.75471591949463ms
Output for 5.5.32
in_array: 1.039901971817ms || by key: 0.7401750087738ms
Output for 5.5.31
in_array: 1.0683209896088ms || by key: 0.73884296417236ms
Output for 5.5.30
in_array: 1.0665941238403ms || by key: 0.7343909740448ms
Output for 5.5.29
in_array: 1.0556421279907ms || by key: 0.74343705177307ms
Output for 5.5.28
in_array: 1.0337491035461ms || by key: 0.7475790977478ms
Output for 5.5.27
in_array: 1.2091188430786ms || by key: 0.92962193489075ms
Output for 5.5.26
in_array: 1.0585820674896ms || by key: 0.7269458770752ms
Output for 5.5.25
in_array: 1.0695858001709ms || by key: 0.72002100944519ms
Output for 5.5.24
in_array: 1.0619580745697ms || by key: 0.62839913368225ms
Output for 5.4.45
in_array: 1.9096071720123ms ||
Process exited with code 137.
Output for 5.4.44
in_array: 1.2308468818665ms ||
Process exited with code 137.
Output for 5.4.43
in_array: 0.97473382949829ms || by key: 0.70229983329773ms
Output for 5.4.42
in_array: 1.8585250377655ms ||
Process exited with code 137.
Output for 5.4.41
in_array: 2.2009198665619ms ||
Process exited with code 137.
Output for 4.3.0 - 4.3.9, 4.4.0, 4.4.3 - 4.4.4, 4.4.6, 5.0.0 - 5.0.5, 5.4.36, 5.4.39 - 5.4.40

Process exited with code 137.
Output for 5.4.38
in_array: 2.127681016922ms ||
Process exited with code 137.
Output for 5.4.37
in_array: 2.2557280063629ms ||
Process exited with code 137.
Output for 5.4.35
in_array: 2.0931150913239ms ||
Process exited with code 137.
Output for 5.4.34
in_array: 1.8197960853577ms ||
Process exited with code 137.
Output for 5.4.32
in_array: 1.437343120575ms ||
Process exited with code 137.
Output for 5.4.31
in_array: 1.2354230880737ms ||
Process exited with code 137.
Output for 5.4.30
in_array: 1.1780290603638ms ||
Process exited with code 137.
Output for 5.4.29
in_array: 1.2083559036255ms ||
Process exited with code 137.
Output for 5.4.28
in_array: 1.372955083847ms ||
Process exited with code 137.
Output for 5.4.27
in_array: 1.493479013443ms ||
Process exited with code 137.
Output for 5.4.26
in_array: 1.1455790996552ms ||
Process exited with code 137.
Output for 5.4.25
in_array: 1.1262431144714ms ||
Process exited with code 137.
Output for 5.4.24
in_array: 1.1157159805298ms ||
Process exited with code 137.
Output for 5.4.23
in_array: 1.3207309246063ms ||
Process exited with code 137.
Output for 5.4.22
in_array: 1.3357150554657ms ||
Process exited with code 137.
Output for 5.4.21
in_array: 1.4292650222778ms ||
Process exited with code 137.
Output for 5.4.20
in_array: 1.1959011554718ms ||
Process exited with code 137.
Output for 5.4.19
in_array: 1.358736038208ms ||
Process exited with code 137.
Output for 5.4.18
in_array: 1.121444940567ms ||
Process exited with code 137.
Output for 5.4.17
in_array: 1.4196021556854ms ||
Process exited with code 137.
Output for 5.4.16
in_array: 1.3549530506134ms ||
Process exited with code 137.
Output for 5.4.15
in_array: 1.1439430713654ms ||
Process exited with code 137.
Output for 5.4.14
in_array: 1.1667940616608ms ||
Process exited with code 137.
Output for 5.4.13
in_array: 1.3907458782196ms ||
Process exited with code 137.
Output for 5.4.12
in_array: 1.3078329563141ms ||
Process exited with code 137.
Output for 5.4.11
in_array: 1.3017230033875ms ||
Process exited with code 137.
Output for 5.4.10
in_array: 1.1900029182434ms ||
Process exited with code 137.
Output for 5.4.9
in_array: 1.1859769821167ms ||
Process exited with code 137.
Output for 5.4.8
in_array: 1.1577658653259ms ||
Process exited with code 137.
Output for 5.4.7
in_array: 1.2228200435638ms ||
Process exited with code 137.
Output for 5.4.6
in_array: 1.3654050827026ms ||
Process exited with code 137.
Output for 5.4.5
in_array: 1.1301369667053ms ||
Process exited with code 137.
Output for 5.4.4
in_array: 1.1505689620972ms ||
Process exited with code 137.
Output for 5.4.3
in_array: 1.210991859436ms ||
Process exited with code 137.
Output for 5.4.2
in_array: 1.1692349910736ms ||
Process exited with code 137.
Output for 5.4.1
in_array: 1.3884840011597ms ||
Process exited with code 137.
Output for 5.4.0
in_array: 1.5203528404236ms ||
Process exited with code 137.
Output for 5.3.29
in_array: 1.3524580001831ms ||
Process exited with code 137.
Output for 5.3.28
in_array: 1.2757411003113ms ||
Process exited with code 137.
Output for 5.3.27
in_array: 1.3081800937653ms ||
Process exited with code 137.
Output for 5.3.26
in_array: 1.2331719398499ms ||
Process exited with code 137.
Output for 5.3.25
in_array: 1.3351998329163ms ||
Process exited with code 137.
Output for 5.3.24
in_array: 1.3174970149994ms ||
Process exited with code 137.
Output for 5.3.23
in_array: 1.2191359996796ms ||
Process exited with code 137.
Output for 5.3.22
in_array: 1.4403920173645ms ||
Process exited with code 137.
Output for 5.3.21
in_array: 1.5550549030304ms ||
Process exited with code 137.
Output for 5.3.20
in_array: 1.2727661132812ms ||
Process exited with code 137.
Output for 5.3.19
in_array: 1.7193551063538ms ||
Process exited with code 137.
Output for 5.3.18
in_array: 1.6944291591644ms ||
Process exited with code 137.
Output for 5.3.17
in_array: 1.5020208358765ms ||
Process exited with code 137.
Output for 5.3.16
in_array: 1.7176120281219ms ||
Process exited with code 137.
Output for 5.3.15
in_array: 1.5886299610138ms ||
Process exited with code 137.
Output for 5.3.14
in_array: 1.4315419197083ms ||
Process exited with code 137.
Output for 5.3.13
in_array: 1.3656740188599ms ||
Process exited with code 137.
Output for 5.3.12
in_array: 1.3019070625305ms ||
Process exited with code 137.
Output for 5.3.11
in_array: 1.3130810260773ms ||
Process exited with code 137.
Output for 5.3.10
in_array: 1.1899259090424ms ||
Process exited with code 137.
Output for 5.3.9
in_array: 1.4563488960266ms ||
Process exited with code 137.
Output for 5.3.8
in_array: 1.3957629203796ms ||
Process exited with code 137.
Output for 5.3.7
in_array: 1.4159119129181ms ||
Process exited with code 137.
Output for 5.3.6
in_array: 1.1833429336548ms ||
Process exited with code 137.
Output for 5.3.5
in_array: 1.2689890861511ms ||
Process exited with code 137.
Output for 5.3.4
in_array: 1.3986070156097ms ||
Process exited with code 137.
Output for 5.3.3
in_array: 1.2692551612854ms ||
Process exited with code 137.
Output for 5.3.2
in_array: 1.2764909267426ms ||
Process exited with code 137.
Output for 5.3.1
in_array: 1.3317220211029ms ||
Process exited with code 137.
Output for 5.3.0
in_array: 1.176646232605ms ||
Process exited with code 137.
Output for 5.2.17
in_array: 1.6466789245605ms ||
Process exited with code 137.
Output for 5.2.16
in_array: 1.2848629951477ms ||
Process exited with code 137.
Output for 5.2.15
in_array: 1.6367471218109ms ||
Process exited with code 137.
Output for 5.2.14
in_array: 1.2599530220032ms ||
Process exited with code 137.
Output for 5.2.13
in_array: 1.2891659736633ms ||
Process exited with code 137.
Output for 5.2.12
in_array: 1.3466618061066ms ||
Process exited with code 137.
Output for 5.2.11
in_array: 1.4025070667267ms ||
Process exited with code 137.
Output for 5.2.10
in_array: 1.2706069946289ms ||
Process exited with code 137.
Output for 5.2.9
in_array: 1.1969289779663ms ||
Process exited with code 137.
Output for 5.2.8
in_array: 1.3410060405731ms ||
Process exited with code 137.
Output for 5.2.7
in_array: 1.2293109893799ms ||
Process exited with code 137.
Output for 5.2.6
in_array: 1.2204360961914ms ||
Process exited with code 137.
Output for 5.2.5
in_array: 1.5558569431305ms ||
Process exited with code 137.
Output for 5.2.4
in_array: 1.3437659740448ms ||
Process exited with code 137.
Output for 5.2.3
in_array: 1.4612691402435ms ||
Process exited with code 137.
Output for 5.2.2
in_array: 1.2928619384766ms ||
Process exited with code 137.
Output for 5.2.1
in_array: 1.9422640800476ms ||
Process exited with code 137.
Output for 5.2.0
in_array: 1.3410978317261ms ||
Process exited with code 137.
Output for 5.1.6
in_array: 1.6095080375671ms ||
Process exited with code 137.
Output for 5.1.5
in_array: 1.4610989093781ms ||
Process exited with code 137.
Output for 5.1.4
in_array: 1.2217478752136ms ||
Process exited with code 137.
Output for 5.1.3
in_array: 1.4551079273224ms ||
Process exited with code 137.
Output for 5.1.2
in_array: 1.304398059845ms ||
Process exited with code 137.
Output for 5.1.1
in_array: 1.3852820396423ms ||
Process exited with code 137.
Output for 5.1.0
in_array: 1.4019701480865ms ||
Process exited with code 137.
Output for 4.4.9
in_array: -0.214594ms ||
Process exited with code 137.
Output for 4.4.8
in_array: -0.090962ms ||
Process exited with code 137.
Output for 4.4.7
in_array: -0.159939ms ||
Process exited with code 137.
Output for 4.4.5
in_array: -0.241523ms ||
Process exited with code 137.
Output for 4.4.2
in_array: -0.066899ms ||
Process exited with code 137.
Output for 4.4.1
in_array: -0.117955ms ||
Process exited with code 137.
Output for 4.3.11
in_array: -0.054891ms ||
Process exited with code 137.
Output for 4.3.10
in_array: -0.163039ms ||
Process exited with code 137.