3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $iter = 100; $array = range(0, $iter); $function = function($val, $key) {}; $t = microtime(true); for($i = 0; $i < $iter; $i++) { foreach($array as $key => $val) { $function($val, $key); } } echo 'foreach '.(microtime(true) - $t); $t = microtime(true); for($i = 0; $i < $iter; $i++) { array_walk($array, $function); } echo ', array_walk '.(microtime(true) - $t); $t = microtime(true); for($i = 0; $i < $iter; $i++) { array_map($function, $array, array_keys($array)); } echo ', array_map '.(microtime(true) - $t);
Output for 7.1.0
foreach 0.00078392028808594, array_walk 0.00092506408691406, array_map 0.00090479850769043
Output for 7.0.14
foreach 0.00064301490783691, array_walk 0.00074982643127441, array_map 0.00084304809570312
Output for 7.0.10
foreach 0.00053882598876953, array_walk 0.00056600570678711, array_map 0.00062799453735352
Output for 7.0.9
foreach 0.00050210952758789, array_walk 0.00055098533630371, array_map 0.00062298774719238
Output for 7.0.8
foreach 0.00071978569030762, array_walk 0.0007939338684082, array_map 0.00090909004211426
Output for 7.0.7
foreach 0.00050711631774902, array_walk 0.00057101249694824, array_map 0.00065493583679199
Output for 7.0.6
foreach 0.00061178207397461, array_walk 0.0010011196136475, array_map 0.0011348724365234
Output for 7.0.5
foreach 0.00053095817565918, array_walk 0.00086808204650879, array_map 0.0017101764678955
Output for 7.0.4
foreach 0.00058197975158691, array_walk 0.0011940002441406, array_map 0.00069308280944824
Output for 7.0.3
foreach 0.00067996978759766, array_walk 0.0010340213775635, array_map 0.0011680126190186
Output for 7.0.2
foreach 0.00037312507629395, array_walk 0.00067710876464844, array_map 0.00069499015808105
Output for 7.0.1
foreach 0.00046491622924805, array_walk 0.00075387954711914, array_map 0.00085997581481934
Output for 7.0.0
foreach 0.00058317184448242, array_walk 0.00099706649780273, array_map 0.0010619163513184
Output for hhvm-3.12.0
foreach 0.0019810199737549, array_walk 0.0017490386962891, array_map 0.0028491020202637
Output for hhvm-3.10.0
foreach 0.0025808811187744, array_walk 0.0020020008087158, array_map 0.0030488967895508
Output for 5.6.28
foreach 0.0021989345550537, array_walk 0.0026340484619141, array_map 0.0038940906524658
Output for 5.6.25
foreach 0.0011129379272461, array_walk 0.0014100074768066, array_map 0.002140998840332
Output for 5.6.24
foreach 0.0016100406646729, array_walk 0.0020279884338379, array_map 0.0029971599578857
Output for 5.6.23
foreach 0.0017440319061279, array_walk 0.0023729801177979, array_map 0.0037260055541992
Output for 5.6.22
foreach 0.0017249584197998, array_walk 0.0021259784698486, array_map 0.0031099319458008
Output for 5.6.21
foreach 0.0018310546875, array_walk 0.0021710395812988, array_map 0.0032510757446289
Output for 5.6.20
foreach 0.0015988349914551, array_walk 0.0029449462890625, array_map 0.0043098926544189
Output for 5.6.19
foreach 0.0014369487762451, array_walk 0.0018069744110107, array_map 0.0030059814453125
Output for 5.6.18
foreach 0.0016460418701172, array_walk 0.00199294090271, array_map 0.0027430057525635
Output for 5.6.17
foreach 0.001378059387207, array_walk 0.0019481182098389, array_map 0.0030181407928467
Output for 5.6.16
foreach 0.0018248558044434, array_walk 0.0023870468139648, array_map 0.0035910606384277
Output for 5.6.15
foreach 0.0015368461608887, array_walk 0.0018861293792725, array_map 0.0028250217437744
Output for 5.6.14
foreach 0.0017349720001221, array_walk 0.0020699501037598, array_map 0.0030918121337891
Output for 5.6.13
foreach 0.0014159679412842, array_walk 0.0017859935760498, array_map 0.002683162689209
Output for 5.6.12
foreach 0.0018138885498047, array_walk 0.0022640228271484, array_map 0.0034430027008057
Output for 5.6.11
foreach 0.0015010833740234, array_walk 0.0017549991607666, array_map 0.002579927444458
Output for 5.6.10
foreach 0.0013720989227295, array_walk 0.0020160675048828, array_map 0.0037519931793213
Output for 5.6.9
foreach 0.0016989707946777, array_walk 0.0021371841430664, array_map 0.0032508373260498
Output for 5.6.8
foreach 0.0014209747314453, array_walk 0.0022711753845215, array_map 0.0027499198913574
Output for 5.6.7
foreach 0.0020639896392822, array_walk 0.002593994140625, array_map 0.0038731098175049
Output for 5.6.6
foreach 0.0016100406646729, array_walk 0.0019609928131104, array_map 0.0034151077270508
Output for 5.6.5
foreach 0.0016789436340332, array_walk 0.0022640228271484, array_map 0.003115177154541
Output for 5.6.4
foreach 0.0016939640045166, array_walk 0.0022170543670654, array_map 0.0031979084014893
Output for 5.6.3
foreach 0.0018088817596436, array_walk 0.0022108554840088, array_map 0.003471851348877
Output for 5.6.2
foreach 0.002032995223999, array_walk 0.002485990524292, array_map 0.0037839412689209
Output for 5.6.1
foreach 0.0017271041870117, array_walk 0.0022170543670654, array_map 0.003389835357666
Output for 5.6.0
foreach 0.0015609264373779, array_walk 0.0019111633300781, array_map 0.0029258728027344
Output for 5.5.38
foreach 0.0012040138244629, array_walk 0.001413106918335, array_map 0.0022728443145752
Output for 5.5.37
foreach 0.0019421577453613, array_walk 0.0024840831756592, array_map 0.003532886505127
Output for 5.5.36
foreach 0.0017647743225098, array_walk 0.0019950866699219, array_map 0.0032949447631836
Output for 5.5.35
foreach 0.0015850067138672, array_walk 0.0019168853759766, array_map 0.0030300617218018
Output for 5.5.34
foreach 0.0019969940185547, array_walk 0.0022079944610596, array_map 0.0035181045532227
Output for 5.5.33
foreach 0.0018820762634277, array_walk 0.0022130012512207, array_map 0.0036079883575439
Output for 5.5.32
foreach 0.0018961429595947, array_walk 0.0021719932556152, array_map 0.0028641223907471
Output for 5.5.31
foreach 0.0011241436004639, array_walk 0.0013799667358398, array_map 0.0024468898773193
Output for 5.5.30
foreach 0.0012118816375732, array_walk 0.0015039443969727, array_map 0.0023360252380371
Output for 5.5.29
foreach 0.001716136932373, array_walk 0.0020780563354492, array_map 0.0033218860626221
Output for 5.5.28
foreach 0.001784086227417, array_walk 0.0023519992828369, array_map 0.0035409927368164
Output for 5.5.27
foreach 0.0023820400238037, array_walk 0.0027320384979248, array_map 0.0063350200653076
Output for 5.5.26
foreach 0.0019040107727051, array_walk 0.0022900104522705, array_map 0.0035960674285889
Output for 5.5.25
foreach 0.0017869472503662, array_walk 0.0021719932556152, array_map 0.0034120082855225
Output for 5.5.24
foreach 0.0025391578674316, array_walk 0.002781867980957, array_map 0.0044741630554199
Output for 5.5.23
foreach 0.002068042755127, array_walk 0.0022709369659424, array_map 0.0022549629211426
Output for 5.5.22
foreach 0.0017268657684326, array_walk 0.0021970272064209, array_map 0.0032749176025391
Output for 5.5.21
foreach 0.0013959407806396, array_walk 0.0016100406646729, array_map 0.0025889873504639
Output for 5.5.20
foreach 0.0015311241149902, array_walk 0.0017609596252441, array_map 0.0028378963470459
Output for 5.5.19
foreach 0.0018150806427002, array_walk 0.0021381378173828, array_map 0.0036509037017822
Output for 5.5.18
foreach 0.0018341541290283, array_walk 0.0021660327911377, array_map 0.0033650398254395
Output for 5.5.16
foreach 0.001521110534668, array_walk 0.0016629695892334, array_map 0.002871036529541
Output for 5.5.15
foreach 0.0013558864593506, array_walk 0.001514196395874, array_map 0.0031309127807617
Output for 5.5.14
foreach 0.0014111995697021, array_walk 0.0017459392547607, array_map 0.0026640892028809
Output for 5.5.13
foreach 0.0011019706726074, array_walk 0.0013480186462402, array_map 0.0021469593048096
Output for 5.5.12
foreach 0.0015640258789062, array_walk 0.0019309520721436, array_map 0.0034830570220947
Output for 5.5.11
foreach 0.0013370513916016, array_walk 0.0016810894012451, array_map 0.003331184387207
Output for 5.5.10
foreach 0.0015139579772949, array_walk 0.0017099380493164, array_map 0.0027132034301758
Output for 5.5.9
foreach 0.0013599395751953, array_walk 0.0017390251159668, array_map 0.002561092376709
Output for 5.5.8
foreach 0.0014369487762451, array_walk 0.0016129016876221, array_map 0.0030519962310791
Output for 5.5.7
foreach 0.0014579296112061, array_walk 0.0017399787902832, array_map 0.0027909278869629
Output for 5.5.6
foreach 0.0028219223022461, array_walk 0.0018448829650879, array_map 0.0029778480529785
Output for 5.5.5
foreach 0.0016090869903564, array_walk 0.0017938613891602, array_map 0.0028440952301025
Output for 5.5.4
foreach 0.0016379356384277, array_walk 0.0018088817596436, array_map 0.0028390884399414
Output for 5.5.3
foreach 0.0019340515136719, array_walk 0.0021429061889648, array_map 0.0035719871520996
Output for 5.5.2
foreach 0.0019309520721436, array_walk 0.0021679401397705, array_map 0.0034611225128174
Output for 5.5.1
foreach 0.0016090869903564, array_walk 0.0018200874328613, array_map 0.0029680728912354
Output for 5.5.0
foreach 0.001910924911499, array_walk 0.0022189617156982, array_map 0.0034859180450439
Output for 5.4.45
foreach 0.0018799304962158, array_walk 0.0021779537200928, array_map 0.0032510757446289
Output for 5.4.44
foreach 0.0021460056304932, array_walk 0.0019190311431885, array_map 0.0033049583435059
Output for 5.4.43
foreach 0.0016560554504395, array_walk 0.0019998550415039, array_map 0.0030531883239746
Output for 5.4.42
foreach 0.0017690658569336, array_walk 0.0020959377288818, array_map 0.0032529830932617
Output for 5.4.41
foreach 0.0018379688262939, array_walk 0.002277135848999, array_map 0.0032269954681396
Output for 5.4.40
foreach 0.0017039775848389, array_walk 0.0015439987182617, array_map 0.0024871826171875
Output for 5.4.39
foreach 0.0017750263214111, array_walk 0.0020909309387207, array_map 0.0032558441162109
Output for 5.4.38
foreach 0.0017988681793213, array_walk 0.0023860931396484, array_map 0.0037930011749268
Output for 5.4.37
foreach 0.0018420219421387, array_walk 0.0020530223846436, array_map 0.0032970905303955
Output for 5.4.36
foreach 0.0018529891967773, array_walk 0.0020380020141602, array_map 0.0028650760650635
Output for 5.4.35
foreach 0.0017440319061279, array_walk 0.002068042755127, array_map 0.0032699108123779
Output for 5.4.34
foreach 0.0019409656524658, array_walk 0.0021710395812988, array_map 0.0034570693969727
Output for 5.4.32
foreach 0.0019750595092773, array_walk 0.0022540092468262, array_map 0.0035490989685059
Output for 5.4.31
foreach 0.0013728141784668, array_walk 0.0015928745269775, array_map 0.0025129318237305
Output for 5.4.30
foreach 0.0014221668243408, array_walk 0.0017380714416504, array_map 0.0026669502258301
Output for 5.4.29
foreach 0.0013489723205566, array_walk 0.0017039775848389, array_map 0.0026030540466309
Output for 5.4.28
foreach 0.0014669895172119, array_walk 0.0016858577728271, array_map 0.0026659965515137
Output for 5.4.27
foreach 0.0026431083679199, array_walk 0.0029449462890625, array_map 0.0044090747833252
Output for 5.4.26
foreach 0.0018010139465332, array_walk 0.002068042755127, array_map 0.0032570362091064
Output for 5.4.25
foreach 0.0020749568939209, array_walk 0.002432107925415, array_map 0.0029408931732178
Output for 5.4.24
foreach 0.0017781257629395, array_walk 0.0019650459289551, array_map 0.0026159286499023
Output for 5.4.23
foreach 0.0019948482513428, array_walk 0.0043380260467529, array_map 0.0029921531677246
Output for 5.4.22
foreach 0.0015699863433838, array_walk 0.0018739700317383, array_map 0.0029060840606689
Output for 5.4.21
foreach 0.0017969608306885, array_walk 0.002180814743042, array_map 0.0033960342407227
Output for 5.4.20
foreach 0.0011789798736572, array_walk 0.0013539791107178, array_map 0.0021491050720215
Output for 5.4.19
foreach 0.0015740394592285, array_walk 0.0018520355224609, array_map 0.0029969215393066
Output for 5.4.18
foreach 0.00164794921875, array_walk 0.001971960067749, array_map 0.0027577877044678
Output for 5.4.17
foreach 0.0017931461334229, array_walk 0.0021660327911377, array_map 0.003450870513916
Output for 5.4.16
foreach 0.0016670227050781, array_walk 0.0020411014556885, array_map 0.0030739307403564
Output for 5.4.15
foreach 0.0015599727630615, array_walk 0.0017521381378174, array_map 0.0028238296508789
Output for 5.4.14
foreach 0.0015990734100342, array_walk 0.0019328594207764, array_map 0.0030281543731689
Output for 5.4.13
foreach 0.0022180080413818, array_walk 0.0020060539245605, array_map 0.0031390190124512
Output for 5.4.12
foreach 0.0018479824066162, array_walk 0.0022659301757812, array_map 0.0034260749816895
Output for 5.4.11
foreach 0.0018391609191895, array_walk 0.0021719932556152, array_map 0.0031270980834961
Output for 5.4.10
foreach 0.0018508434295654, array_walk 0.0020952224731445, array_map 0.0033531188964844
Output for 5.4.9
foreach 0.001345157623291, array_walk 0.0019397735595703, array_map 0.0025229454040527
Output for 5.4.8
foreach 0.0017399787902832, array_walk 0.0016520023345947, array_map 0.0026500225067139
Output for 5.4.7
foreach 0.0013799667358398, array_walk 0.0016779899597168, array_map 0.0025050640106201
Output for 5.4.6
foreach 0.0015649795532227, array_walk 0.0017731189727783, array_map 0.0028181076049805
Output for 5.4.5
foreach 0.0018470287322998, array_walk 0.002133846282959, array_map 0.0032439231872559
Output for 5.4.4
foreach 0.0028660297393799, array_walk 0.0038080215454102, array_map 0.004194974899292
Output for 5.4.3
foreach 0.0015239715576172, array_walk 0.0019350051879883, array_map 0.0028808116912842
Output for 5.4.2
foreach 0.0018398761749268, array_walk 0.0021140575408936, array_map 0.003532886505127
Output for 5.4.1
foreach 0.0019850730895996, array_walk 0.0023519992828369, array_map 0.0035989284515381
Output for 5.4.0
foreach 0.001978874206543, array_walk 0.0024118423461914, array_map 0.0036599636077881
Output for 5.3.29
foreach 0.0018529891967773, array_walk 0.0019690990447998, array_map 0.0031058788299561
Output for 5.3.28
foreach 0.0018599033355713, array_walk 0.0020129680633545, array_map 0.0030031204223633
Output for 5.3.27
foreach 0.0022690296173096, array_walk 0.0022790431976318, array_map 0.0029261112213135
Output for 5.3.26
foreach 0.0022459030151367, array_walk 0.0026650428771973, array_map 0.0039150714874268
Output for 5.3.25
foreach 0.0022239685058594, array_walk 0.0024740695953369, array_map 0.0032680034637451
Output for 5.3.24
foreach 0.0022470951080322, array_walk 0.0024271011352539, array_map 0.0037169456481934
Output for 5.3.23
foreach 0.0022029876708984, array_walk 0.0024878978729248, array_map 0.0048060417175293
Output for 5.3.22
foreach 0.0020968914031982, array_walk 0.0023219585418701, array_map 0.0035948753356934
Output for 5.3.21
foreach 0.0016129016876221, array_walk 0.0019159317016602, array_map 0.0028200149536133
Output for 5.3.20
foreach 0.0019609928131104, array_walk 0.002249002456665, array_map 0.0032579898834229
Output for 5.3.19
foreach 0.0016582012176514, array_walk 0.0022709369659424, array_map 0.0039019584655762
Output for 5.3.18
foreach 0.0014431476593018, array_walk 0.0016019344329834, array_map 0.0024778842926025
Output for 5.3.17
foreach 0.0019011497497559, array_walk 0.0021648406982422, array_map 0.0043370723724365
Output for 5.3.16
foreach 0.0021188259124756, array_walk 0.0021669864654541, array_map 0.0032639503479004
Output for 5.3.15
foreach 0.0016839504241943, array_walk 0.0017478466033936, array_map 0.0023679733276367
Output for 5.3.14
foreach 0.0019149780273438, array_walk 0.0022320747375488, array_map 0.0029919147491455
Output for 5.3.13
foreach 0.0013189315795898, array_walk 0.0014500617980957, array_map 0.0026791095733643
Output for 5.3.12
foreach 0.0021610260009766, array_walk 0.0024251937866211, array_map 0.003525972366333
Output for 5.3.11
foreach 0.0011379718780518, array_walk 0.0015101432800293, array_map 0.0020930767059326
Output for 5.3.10
foreach 0.0019419193267822, array_walk 0.0022540092468262, array_map 0.0033249855041504
Output for 5.3.9
foreach 0.0022308826446533, array_walk 0.0025079250335693, array_map 0.0036919116973877
Output for 5.3.8
foreach 0.0026021003723145, array_walk 0.002295970916748, array_map 0.0028750896453857
Output for 5.3.7
foreach 0.0017290115356445, array_walk 0.0018620491027832, array_map 0.0030028820037842
Output for 5.3.6
foreach 0.0045149326324463, array_walk 0.004788875579834, array_map 0.0067689418792725
Output for 5.3.5
foreach 0.0019629001617432, array_walk 0.0021250247955322, array_map 0.0033102035522461
Output for 5.3.4
foreach 0.0019900798797607, array_walk 0.0021121501922607, array_map 0.0032570362091064
Output for 5.3.3
foreach 0.0020039081573486, array_walk 0.0022640228271484, array_map 0.0034070014953613
Output for 5.3.2
foreach 0.0020639896392822, array_walk 0.0021200180053711, array_map 0.0027718544006348
Output for 5.3.1
foreach 0.00193190574646, array_walk 0.0019669532775879, array_map 0.0030009746551514
Output for 5.3.0
foreach 0.0024070739746094, array_walk 0.0024209022521973, array_map 0.0037288665771484
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/JB9LP on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/JB9LP on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/JB9LP on line 5
Process exited with code 255.