3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(0); $amount = 100; $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(isset($alreadyOutput[$num])){ continue; } $alreadyOutput[$num] = true; } echo "by key: ".(microtime(true) - $start2)."ms";
based on k9T3X
Output for 7.1.0
in_array: 4.9114227294922E-5ms || by key: 2.7894973754883E-5ms
Output for 7.0.14
in_array: 3.504753112793E-5ms || by key: 1.8119812011719E-5ms
Output for 7.0.6
in_array: 2.0980834960938E-5ms || by key: 1.0013580322266E-5ms
Output for 7.0.5
in_array: 3.0994415283203E-5ms || by key: 1.6927719116211E-5ms
Output for 7.0.4
in_array: 3.7908554077148E-5ms || by key: 1.5974044799805E-5ms
Output for 7.0.3
in_array: 3.3855438232422E-5ms || by key: 1.4066696166992E-5ms
Output for 7.0.2
in_array: 3.2901763916016E-5ms || by key: 1.5020370483398E-5ms
Output for 7.0.1
in_array: 3.6954879760742E-5ms || by key: 1.6927719116211E-5ms
Output for 7.0.0
in_array: 3.6001205444336E-5ms || by key: 1.6927719116211E-5ms
Output for hhvm-3.12.0
in_array: 0.00012898445129395ms || by key: 2.0980834960938E-5ms
Output for hhvm-3.10.0
in_array: 0.00016188621520996ms || by key: 2.288818359375E-5ms
Output for 5.6.28
in_array: 0.00016617774963379ms || by key: 4.9114227294922E-5ms
Output for 5.6.21
in_array: 0.00011396408081055ms || by key: 3.0040740966797E-5ms
Output for 5.6.20
in_array: 0.00011205673217773ms || by key: 2.8133392333984E-5ms
Output for 5.6.19
in_array: 7.2956085205078E-5ms || by key: 1.8835067749023E-5ms
Output for 5.6.18
in_array: 7.6055526733398E-5ms || by key: 2.9087066650391E-5ms
Output for 5.6.17
in_array: 7.4863433837891E-5ms || by key: 1.978874206543E-5ms
Output for 5.6.16
in_array: 7.7009201049805E-5ms || by key: 1.8835067749023E-5ms
Output for 5.6.15
in_array: 0.00012707710266113ms || by key: 3.0994415283203E-5ms
Output for 5.6.14
in_array: 8.082389831543E-5ms || by key: 2.288818359375E-5ms
Output for 5.6.13
in_array: 7.3909759521484E-5ms || by key: 2.0027160644531E-5ms
Output for 5.6.12
in_array: 9.0122222900391E-5ms || by key: 2.1934509277344E-5ms
Output for 5.6.11
in_array: 0.00019097328186035ms || by key: 7.3909759521484E-5ms
Output for 5.6.10
in_array: 0.00012493133544922ms || by key: 3.0040740966797E-5ms
Output for 5.6.9
in_array: 7.176399230957E-5ms || by key: 2.0027160644531E-5ms
Output for 5.6.8
in_array: 0.00013303756713867ms || by key: 3.0994415283203E-5ms
Output for 5.5.35
in_array: 0.00011515617370605ms || by key: 2.7179718017578E-5ms
Output for 5.5.34
in_array: 0.0001220703125ms || by key: 3.0994415283203E-5ms
Output for 5.5.33
in_array: 8.6069107055664E-5ms || by key: 2.0980834960938E-5ms
Output for 5.5.32
in_array: 8.4877014160156E-5ms || by key: 2.0027160644531E-5ms
Output for 5.5.31
in_array: 0.00010299682617188ms || by key: 2.5033950805664E-5ms
Output for 5.5.30
in_array: 0.00013113021850586ms || by key: 3.504753112793E-5ms
Output for 5.3.14, 5.5.29
in_array: 0.00010395050048828ms || by key: 2.5033950805664E-5ms
Output for 5.4.12, 5.5.28
in_array: 0.00013113021850586ms || by key: 2.1934509277344E-5ms
Output for 5.5.27
in_array: 9.5844268798828E-5ms || by key: 2.598762512207E-5ms
Output for 5.5.26
in_array: 0.00014090538024902ms || by key: 3.1948089599609E-5ms
Output for 5.5.25
in_array: 0.00011897087097168ms || by key: 3.6954879760742E-5ms
Output for 5.5.24
in_array: 0.00012683868408203ms || by key: 3.2186508178711E-5ms
Output for 5.4.45
in_array: 0.00011086463928223ms || by key: 3.4093856811523E-5ms
Output for 5.4.44
in_array: 9.8943710327148E-5ms || by key: 2.8848648071289E-5ms
Output for 5.4.43
in_array: 0.00012087821960449ms || by key: 3.4093856811523E-5ms
Output for 5.4.42
in_array: 0.00011515617370605ms || by key: 2.6941299438477E-5ms
Output for 5.4.41
in_array: 0.00010800361633301ms || by key: 3.1948089599609E-5ms
Output for 5.4.40
in_array: 0.00010395050048828ms || by key: 3.2901763916016E-5ms
Output for 5.4.39
in_array: 0.00011396408081055ms || by key: 2.7894973754883E-5ms
Output for 5.4.38
in_array: 0.00015401840209961ms || by key: 3.2186508178711E-5ms
Output for 5.4.37
in_array: 0.00018715858459473ms || by key: 2.8848648071289E-5ms
Output for 5.4.36
in_array: 0.00011706352233887ms || by key: 2.8133392333984E-5ms
Output for 5.4.35
in_array: 0.00016188621520996ms || by key: 3.7908554077148E-5ms
Output for 5.4.34
in_array: 0.00017714500427246ms || by key: 4.4107437133789E-5ms
Output for 5.4.32
in_array: 8.2015991210938E-5ms || by key: 2.0980834960938E-5ms
Output for 5.4.31
in_array: 0.00013279914855957ms || by key: 3.814697265625E-5ms
Output for 5.4.30
in_array: 8.702278137207E-5ms || by key: 2.0980834960938E-5ms
Output for 5.4.29
in_array: 0.00011181831359863ms || by key: 2.4080276489258E-5ms
Output for 5.4.28
in_array: 0.00010108947753906ms || by key: 3.2901763916016E-5ms
Output for 5.4.27
in_array: 0.00012516975402832ms || by key: 2.0980834960938E-5ms
Output for 5.4.26
in_array: 9.8943710327148E-5ms || by key: 1.978874206543E-5ms
Output for 5.4.25
in_array: 0.00013995170593262ms || by key: 4.4822692871094E-5ms
Output for 5.4.24
in_array: 8.2969665527344E-5ms || by key: 2.0027160644531E-5ms
Output for 5.4.23
in_array: 0.00010585784912109ms || by key: 2.1934509277344E-5ms
Output for 5.4.16, 5.4.22
in_array: 8.2969665527344E-5ms || by key: 2.0980834960938E-5ms
Output for 5.4.21
in_array: 8.1062316894531E-5ms || by key: 2.9802322387695E-5ms
Output for 5.4.20
in_array: 7.7962875366211E-5ms || by key: 2.0027160644531E-5ms
Output for 5.4.19
in_array: 9.5844268798828E-5ms || by key: 2.0980834960938E-5ms
Output for 5.4.18
in_array: 8.4877014160156E-5ms || by key: 2.0980834960938E-5ms
Output for 5.4.17
in_array: 8.6069107055664E-5ms || by key: 2.4080276489258E-5ms
Output for 5.3.11, 5.4.15
in_array: 9.2983245849609E-5ms || by key: 3.0040740966797E-5ms
Output for 5.4.14
in_array: 8.392333984375E-5ms || by key: 2.0980834960938E-5ms
Output for 5.4.13
in_array: 0.00010514259338379ms || by key: 2.598762512207E-5ms
Output for 5.4.11
in_array: 9.3936920166016E-5ms || by key: 2.5033950805664E-5ms
Output for 5.4.10
in_array: 0.00011897087097168ms || by key: 2.1934509277344E-5ms
Output for 5.4.9
in_array: 0.00010395050048828ms || by key: 2.0980834960938E-5ms
Output for 5.4.8
in_array: 8.7976455688477E-5ms || by key: 2.1934509277344E-5ms
Output for 5.4.7
in_array: 8.9883804321289E-5ms || by key: 2.288818359375E-5ms
Output for 5.4.6
in_array: 0.00010299682617188ms || by key: 3.1948089599609E-5ms
Output for 5.4.5
in_array: 9.5129013061523E-5ms || by key: 3.0994415283203E-5ms
Output for 5.4.4
in_array: 9.9897384643555E-5ms || by key: 2.1934509277344E-5ms
Output for 5.4.3
in_array: 9.3936920166016E-5ms || by key: 2.2172927856445E-5ms
Output for 5.4.2
in_array: 8.8930130004883E-5ms || by key: 3.0994415283203E-5ms
Output for 5.4.1
in_array: 8.9883804321289E-5ms || by key: 0ms
Output for 5.4.0
in_array: 9.5844268798828E-5ms || by key: 2.2172927856445E-5ms
Output for 5.3.29
in_array: 8.0108642578125E-5ms || by key: 2.6941299438477E-5ms
Output for 5.3.28
in_array: 9.8943710327148E-5ms || by key: 2.7894973754883E-5ms
Output for 5.3.27
in_array: 0.00015616416931152ms || by key: 4.6014785766602E-5ms
Output for 5.3.26
in_array: 0.00010108947753906ms || by key: 2.5033950805664E-5ms
Output for 5.3.25
in_array: 9.9897384643555E-5ms || by key: 2.0980834960938E-5ms
Output for 5.3.24
in_array: 8.2015991210938E-5ms || by key: 2.3841857910156E-5ms
Output for 5.3.23
in_array: 8.6069107055664E-5ms || by key: 2.598762512207E-5ms
Output for 5.3.18, 5.3.22
in_array: 8.7976455688477E-5ms || by key: 2.3126602172852E-5ms
Output for 5.3.21
in_array: 9.2983245849609E-5ms || by key: 3.3855438232422E-5ms
Output for 5.3.20
in_array: 9.0122222900391E-5ms || by key: 2.3126602172852E-5ms
Output for 5.3.19
in_array: 8.5115432739258E-5ms || by key: 3.6001205444336E-5ms
Output for 5.3.17
in_array: 8.392333984375E-5ms || by key: 2.288818359375E-5ms
Output for 5.3.16
in_array: 8.702278137207E-5ms || by key: 2.6941299438477E-5ms
Output for 5.3.15
in_array: 9.4175338745117E-5ms || by key: 2.3841857910156E-5ms
Output for 5.3.13
in_array: 9.2983245849609E-5ms || by key: 2.5033950805664E-5ms
Output for 5.3.12
in_array: 9.7990036010742E-5ms || by key: 2.3841857910156E-5ms
Output for 5.3.10
in_array: 8.9883804321289E-5ms || by key: 2.598762512207E-5ms
Output for 5.3.8 - 5.3.9
in_array: 9.1075897216797E-5ms || by key: 2.3126602172852E-5ms
Output for 5.3.7
in_array: 8.5115432739258E-5ms || by key: 2.288818359375E-5ms
Output for 5.3.6
in_array: 0.0001378059387207ms || by key: 2.3126602172852E-5ms
Output for 5.3.5
in_array: 9.7990036010742E-5ms || by key: 6.6995620727539E-5ms
Output for 5.3.4
in_array: 8.8930130004883E-5ms || by key: 2.4080276489258E-5ms
Output for 5.3.3
in_array: 0.00011897087097168ms || by key: 2.3126602172852E-5ms
Output for 5.3.2
in_array: 9.7036361694336E-5ms || by key: 2.3126602172852E-5ms
Output for 5.3.1
in_array: 9.1075897216797E-5ms || by key: 2.4080276489258E-5ms
Output for 5.3.0
in_array: 0.00012803077697754ms || by key: 2.4080276489258E-5ms
Output for 5.2.17
in_array: 0.00011205673217773ms || by key: 2.598762512207E-5ms
Output for 5.2.16
in_array: 0.00019311904907227ms || by key: 4.6014785766602E-5ms
Output for 5.2.15
in_array: 0.00011992454528809ms || by key: 2.8848648071289E-5ms
Output for 5.2.14
in_array: 0.00013017654418945ms || by key: 2.598762512207E-5ms
Output for 5.2.13
in_array: 0.00013017654418945ms || by key: 2.6941299438477E-5ms
Output for 5.2.12
in_array: 0.00011897087097168ms || by key: 2.598762512207E-5ms
Output for 5.2.11
in_array: 0.0001068115234375ms || by key: 2.598762512207E-5ms
Output for 5.2.10
in_array: 0.0001380443572998ms || by key: 2.4795532226562E-5ms
Output for 5.2.9
in_array: 0.00011420249938965ms || by key: 2.7894973754883E-5ms
Output for 5.2.8
in_array: 0.00011396408081055ms || by key: 2.8848648071289E-5ms
Output for 5.2.7
in_array: 0.00013089179992676ms || by key: 3.7908554077148E-5ms
Output for 5.2.6
in_array: 0.00014710426330566ms || by key: 2.598762512207E-5ms
Output for 5.2.5
in_array: 0.00012898445129395ms || by key: 2.598762512207E-5ms
Output for 5.2.4
in_array: 0.00012087821960449ms || by key: 2.7179718017578E-5ms
Output for 5.2.3
in_array: 0.00010895729064941ms || by key: 2.5033950805664E-5ms
Output for 5.2.2
in_array: 0.00012421607971191ms || by key: 4.1961669921875E-5ms
Output for 5.2.1
in_array: 0.00011396408081055ms || by key: 2.5033950805664E-05ms
Output for 5.2.0
in_array: 0.00010180473327637ms || by key: 2.6941299438477E-05ms
Output for 5.1.6
in_array: 0.00015401840209961ms || by key: 2.3126602172852E-05ms
Output for 5.1.5
in_array: 0.00012302398681641ms || by key: 2.4080276489258E-05ms
Output for 5.1.4
in_array: 0.00012087821960449ms || by key: 2.5033950805664E-05ms
Output for 5.1.3
in_array: 0.00011205673217773ms || by key: 2.3841857910156E-05ms
Output for 5.1.2
in_array: 0.00010585784912109ms || by key: 2.4080276489258E-05ms
Output for 5.1.1
in_array: 0.00011301040649414ms || by key: 4.1007995605469E-05ms
Output for 5.1.0
in_array: 0.00012087821960449ms || by key: 2.6941299438477E-05ms
Output for 5.0.5
in_array: 0.00016117095947266ms || by key: 5.0067901611328E-05ms
Output for 5.0.4
in_array: 0.00016283988952637ms || by key: 7.9870223999023E-05ms
Output for 5.0.3
in_array: 0.00013494491577148ms || by key: 5.3167343139648E-05ms
Output for 5.0.2
in_array: 0.00014400482177734ms || by key: 9.9897384643555E-05ms
Output for 5.0.1
in_array: 0.00014114379882812ms || by key: 7.4863433837891E-05ms
Output for 5.0.0
in_array: 0.0001370906829834ms || by key: 7.3909759521484E-05ms
Output for 4.4.9
in_array: 0.00028999999999998ms || by key: 5.4999999999999E-05ms
Output for 4.4.8
in_array: 0.00014700000000001ms || by key: 9.1000000000008E-05ms
Output for 4.4.7
in_array: 0.00015500000000002ms || by key: 5.4999999999999E-05ms
Output for 4.4.6
in_array: 0.000137ms || by key: 8.0999999999998E-05ms
Output for 4.4.5
in_array: 0.00015700000000002ms || by key: 5.6E-05ms
Output for 4.4.4
in_array: 0.000168ms || by key: 5.7000000000029E-05ms
Output for 4.4.3
in_array: 0.00014999999999998ms || by key: 0.00011ms
Output for 4.4.2
in_array: 0.00013799999999997ms || by key: 6.0000000000004E-05ms
Output for 4.4.1
in_array: 0.000139ms || by key: 5.8999999999976E-05ms
Output for 4.4.0
in_array: 0.000197ms || by key: 5.6E-05ms
Output for 4.3.11
in_array: 0.000168ms || by key: 9.300000000001E-05ms
Output for 4.3.10
in_array: 0.00014500000000001ms || by key: 5.6999999999974E-05ms
Output for 4.3.9
in_array: 0.00018000000000001ms || by key: 8.2000000000026E-05ms
Output for 4.3.8
in_array: 0.00017200000000006ms || by key: 8.3000000000055E-05ms
Output for 4.3.7
in_array: 0.00014999999999998ms || by key: 8.5000000000002E-05ms
Output for 4.3.6
in_array: 0.00015399999999999ms || by key: 8.7000000000059E-05ms
Output for 4.3.5
in_array: 0.00015900000000002ms || by key: 5.6999999999974E-05ms
Output for 4.3.4
in_array: 0.00017ms || by key: 7.9999999999969E-05ms
Output for 4.3.3
in_array: 0.00015100000000001ms || by key: 5.3999999999998E-05ms
Output for 4.3.2
in_array: 0.00027200000000005ms || by key: 0.00021300000000002ms
Output for 4.3.1
in_array: 0.00027699999999997ms || by key: 0.00021700000000002ms
Output for 4.3.0
in_array: 0.00034400000000001ms || by key: 0.00023399999999996ms