3v4l.org

run code in 300+ PHP versions simultaneously
<?php $loops = 100000; $start = microtime(true); for ($l = 0; $l < $loops; $l++) { $x = [1,2,3,4,6,7,8,9]; for ($i = 0; $i <= 10; $i++) { if (!in_array($i, $x)) { $x[] = $i; } } } $duration = microtime(true) - $start; echo "in_array took $duration<br>".PHP_EOL; $start = microtime(true); for ($l = 0; $l < $loops; $l++) { $x = [1,2,3,4,6,7,8,9]; $x = array_values(array_unique(array_merge($x, [0,1,2,3,4,5,6,7,8,9,10]))); } $duration = microtime(true) - $start; echo "array_unique took $duration<br>".PHP_EOL;
Output for 8.1.9
in_array took 0.040000915527344<br> array_unique took 0.055959939956665<br>
Output for 8.1.8
in_array took 0.038674116134644<br> array_unique took 0.058502912521362<br>
Output for 8.1.7
in_array took 0.036305904388428<br> array_unique took 0.054364204406738<br>
Output for 8.1.6
in_array took 0.036252975463867<br> array_unique took 0.061725854873657<br>
Output for 8.1.5
in_array took 0.035141944885254<br> array_unique took 0.054740190505981<br>
Output for 8.1.4
in_array took 0.037929058074951<br> array_unique took 0.057888984680176<br>
Output for 8.1.3
in_array took 0.036491870880127<br> array_unique took 0.058816909790039<br>
Output for 8.1.2
in_array took 0.035382032394409<br> array_unique took 0.055884122848511<br>
Output for 8.1.1
in_array took 0.035769939422607<br> array_unique took 0.056778192520142<br>
Output for 8.1.0
in_array took 0.037605047225952<br> array_unique took 0.0590980052948<br>
Output for 8.0.22
in_array took 0.036291837692261<br> array_unique took 0.055129051208496<br>
Output for 8.0.21
in_array took 0.040157079696655<br> array_unique took 0.05635404586792<br>
Output for 8.0.20
in_array took 0.035295009613037<br> array_unique took 0.055943965911865<br>
Output for 8.0.19
in_array took 0.039062023162842<br> array_unique took 0.056406021118164<br>
Output for 8.0.18
in_array took 0.036107063293457<br> array_unique took 0.055822849273682<br>
Output for 8.0.17
in_array took 0.036868095397949<br> array_unique took 0.05816912651062<br>
Output for 8.0.16
in_array took 0.037259101867676<br> array_unique took 0.054340124130249<br>
Output for 8.0.15
in_array took 0.035272121429443<br> array_unique took 0.055827856063843<br>
Output for 8.0.14
in_array took 0.039915084838867<br> array_unique took 0.062078952789307<br>
Output for 8.0.13
in_array took 0.047986030578613<br> array_unique took 0.056295871734619<br>
Output for 8.0.12
in_array took 0.039618015289307<br> array_unique took 0.066711902618408<br>
Output for 8.0.11
in_array took 0.042757034301758<br> array_unique took 0.070529937744141<br>
Output for 8.0.10
in_array took 0.044719219207764<br> array_unique took 0.068253040313721<br>
Output for 8.0.9
in_array took 0.04167103767395<br> array_unique took 0.068289995193481<br>
Output for 8.0.8
in_array took 0.049225091934204<br> array_unique took 0.066176891326904<br>
Output for 8.0.7
in_array took 0.047016859054565<br> array_unique took 0.067265033721924<br>
Output for 8.0.6
in_array took 0.044080018997192<br> array_unique took 0.068784952163696<br>
Output for 8.0.5
in_array took 0.047307968139648<br> array_unique took 0.070050001144409<br>
Output for 8.0.3
in_array took 0.047785997390747<br> array_unique took 0.064974069595337<br>
Output for 8.0.2
in_array took 0.043304204940796<br> array_unique took 0.062750101089478<br>
Output for 8.0.1
in_array took 0.047028064727783<br> array_unique took 0.066154003143311<br>
Output for 8.0.0
in_array took 0.038774013519287<br> array_unique took 0.055254936218262<br>
Output for 7.4.30
in_array took 0.043398857116699<br> array_unique took 0.057604074478149<br>
Output for 7.4.29
in_array took 0.043233156204224<br> array_unique took 0.05724310874939<br>
Output for 7.4.28
in_array took 0.044296979904175<br> array_unique took 0.057963848114014<br>
Output for 7.4.27
in_array took 0.044934034347534<br> array_unique took 0.057174921035767<br>
Output for 7.4.26
in_array took 0.045474052429199<br> array_unique took 0.056668043136597<br>
Output for 7.4.25
in_array took 0.040908098220825<br> array_unique took 0.058416843414307<br>
Output for 7.4.24
in_array took 0.045561075210571<br> array_unique took 0.055974006652832<br>
Output for 7.4.23
in_array took 0.044190883636475<br> array_unique took 0.057238817214966<br>
Output for 7.4.22
in_array took 0.039967060089111<br> array_unique took 0.056005954742432<br>
Output for 7.4.21
in_array took 0.04045295715332<br> array_unique took 0.056926012039185<br>
Output for 7.4.20
in_array took 0.0399329662323<br> array_unique took 0.058921098709106<br>
Output for 7.4.19
in_array took 0.040444135665894<br> array_unique took 0.057590007781982<br>
Output for 7.4.18
in_array took 0.040053844451904<br> array_unique took 0.057369947433472<br>
Output for 7.4.16
in_array took 0.039523124694824<br> array_unique took 0.056726217269897<br>
Output for 7.4.15
in_array took 0.041987180709839<br> array_unique took 0.057523965835571<br>
Output for 7.4.14
in_array took 0.04236102104187<br> array_unique took 0.057227849960327<br>
Output for 7.4.13
in_array took 0.042349815368652<br> array_unique took 0.057858943939209<br>
Output for 7.4.12
in_array took 0.039726972579956<br> array_unique took 0.056183099746704<br>
Output for 7.4.11
in_array took 0.042580842971802<br> array_unique took 0.055650949478149<br>
Output for 7.4.10
in_array took 0.041501045227051<br> array_unique took 0.058007001876831<br>
Output for 7.4.9
in_array took 0.044195890426636<br> array_unique took 0.05617094039917<br>
Output for 7.4.8
in_array took 0.038386106491089<br> array_unique took 0.054044961929321<br>
Output for 7.4.7
in_array took 0.039823055267334<br> array_unique took 0.056639909744263<br>
Output for 7.4.6
in_array took 0.040588140487671<br> array_unique took 0.055660009384155<br>
Output for 7.4.5
in_array took 0.039884090423584<br> array_unique took 0.057468891143799<br>
Output for 7.4.4
in_array took 0.042675971984863<br> array_unique took 0.055156946182251<br>
Output for 7.4.3
in_array took 0.041692972183228<br> array_unique took 0.05706000328064<br>
Output for 7.4.2
in_array took 0.04258394241333<br> array_unique took 0.054574012756348<br>
Output for 7.4.1
in_array took 0.041741132736206<br> array_unique took 0.057313919067383<br>
Output for 7.4.0
in_array took 0.040436983108521<br> array_unique took 0.056680917739868<br>
Output for 7.3.33
in_array took 0.046430110931396<br> array_unique took 0.058298110961914<br>
Output for 7.3.32
in_array took 0.048296928405762<br> array_unique took 0.057075977325439<br>
Output for 7.3.31
in_array took 0.049763917922974<br> array_unique took 0.059170961380005<br>
Output for 7.3.30
in_array took 0.047885179519653<br> array_unique took 0.057827949523926<br>
Output for 7.3.29
in_array took 0.048017978668213<br> array_unique took 0.057056903839111<br>
Output for 7.3.28
in_array took 0.049129962921143<br> array_unique took 0.058411121368408<br>
Output for 7.3.27
in_array took 0.048887968063354<br> array_unique took 0.061874866485596<br>
Output for 7.3.26
in_array took 0.056437015533447<br> array_unique took 0.065820932388306<br>
Output for 7.3.25
in_array took 0.055168867111206<br> array_unique took 0.069693088531494<br>
Output for 7.3.24
in_array took 0.056922912597656<br> array_unique took 0.069566965103149<br>
Output for 7.3.23
in_array took 0.055002927780151<br> array_unique took 0.060792207717896<br>
Output for 7.3.22
in_array took 0.058969974517822<br> array_unique took 0.064960956573486<br>
Output for 7.3.21
in_array took 0.055075168609619<br> array_unique took 0.066977977752686<br>
Output for 7.3.20
in_array took 0.052343845367432<br> array_unique took 0.065915107727051<br>
Output for 7.3.19
in_array took 0.054330110549927<br> array_unique took 0.064691066741943<br>
Output for 7.3.18
in_array took 0.053898096084595<br> array_unique took 0.068973064422607<br>
Output for 7.3.17
in_array took 0.057782173156738<br> array_unique took 0.06604790687561<br>
Output for 7.3.16
in_array took 0.05079197883606<br> array_unique took 0.059977054595947<br>
Output for 7.3.15
in_array took 0.050046920776367<br> array_unique took 0.064810991287231<br>
Output for 7.3.14
in_array took 0.04737401008606<br> array_unique took 0.069138050079346<br>
Output for 7.3.13
in_array took 0.049043893814087<br> array_unique took 0.057346105575562<br>
Output for 7.3.12
in_array took 0.044610023498535<br> array_unique took 0.055186033248901<br>
Output for 7.3.11
in_array took 0.04741096496582<br> array_unique took 0.056437969207764<br>
Output for 7.3.10
in_array took 0.053980827331543<br> array_unique took 0.056951999664307<br>
Output for 7.3.9
in_array took 0.051828861236572<br> array_unique took 0.055405139923096<br>
Output for 7.3.8
in_array took 0.049487829208374<br> array_unique took 0.054509878158569<br>
Output for 7.3.7
in_array took 0.050134897232056<br> array_unique took 0.054702043533325<br>
Output for 7.3.6
in_array took 0.04797101020813<br> array_unique took 0.058211088180542<br>
Output for 7.3.5
in_array took 0.051785945892334<br> array_unique took 0.058302879333496<br>
Output for 7.3.4
in_array took 0.049263954162598<br> array_unique took 0.057163953781128<br>
Output for 7.3.3
in_array took 0.047538042068481<br> array_unique took 0.0568528175354<br>
Output for 7.3.2
in_array took 0.045037031173706<br> array_unique took 0.057425022125244<br>
Output for 7.3.1
in_array took 0.045727014541626<br> array_unique took 0.053429126739502<br>
Output for 7.3.0
in_array took 0.047507047653198<br> array_unique took 0.053945064544678<br>

preferences:
122.83 ms | 401 KiB | 101 Q