3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $iter = 100; $array = range(0, $iter); $function = function($val, $key = null) {}; $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.0006868839263916, array_walk 0.00088810920715332, array_map 0.00085902214050293
Output for 7.0.14
foreach 0.0006561279296875, array_walk 0.00074911117553711, array_map 0.00084519386291504
Output for 7.0.10
foreach 0.00047183036804199, array_walk 0.00052499771118164, array_map 0.00057482719421387
Output for 7.0.9
foreach 0.00052618980407715, array_walk 0.00052499771118164, array_map 0.00065493583679199
Output for 7.0.8
foreach 0.00038504600524902, array_walk 0.00042891502380371, array_map 0.00068879127502441
Output for 7.0.7
foreach 0.00053000450134277, array_walk 0.00059700012207031, array_map 0.00065898895263672
Output for 7.0.6
foreach 0.00052881240844727, array_walk 0.00098800659179688, array_map 0.00081586837768555
Output for 7.0.5
foreach 0.000640869140625, array_walk 0.0011839866638184, array_map 0.0013048648834229
Output for 7.0.4
foreach 0.0005948543548584, array_walk 0.00093293190002441, array_map 0.0010719299316406
Output for 7.0.3
foreach 0.00061607360839844, array_walk 0.00096583366394043, array_map 0.0010859966278076
Output for 7.0.2
foreach 0.00042510032653809, array_walk 0.0007331371307373, array_map 0.00078201293945312
Output for 7.0.1
foreach 0.00061488151550293, array_walk 0.0010020732879639, array_map 0.0011630058288574
Output for 7.0.0
foreach 0.00037503242492676, array_walk 0.00061607360839844, array_map 0.00067782402038574
Output for 5.6.28
foreach 0.0023419857025146, array_walk 0.0024330615997314, array_map 0.0038070678710938
Output for 5.6.25
foreach 0.0015149116516113, array_walk 0.0020761489868164, array_map 0.0031118392944336
Output for 5.6.24
foreach 0.0019371509552002, array_walk 0.0024740695953369, array_map 0.0039610862731934
Output for 5.6.23
foreach 0.0019919872283936, array_walk 0.0023279190063477, array_map 0.0034270286560059
Output for 5.6.22
foreach 0.0016410350799561, array_walk 0.0018110275268555, array_map 0.0024421215057373
Output for 5.6.21
foreach 0.0015738010406494, array_walk 0.0020689964294434, array_map 0.0030698776245117
Output for 5.6.20
foreach 0.0014169216156006, array_walk 0.0017549991607666, array_map 0.0026669502258301
Output for 5.6.19
foreach 0.0011770725250244, array_walk 0.0015659332275391, array_map 0.0022859573364258
Output for 5.6.18
foreach 0.0013411045074463, array_walk 0.0017149448394775, array_map 0.0025920867919922
Output for 5.6.17
foreach 0.0017929077148438, array_walk 0.0022759437561035, array_map 0.0034210681915283
Output for 5.6.16
foreach 0.0011639595031738, array_walk 0.0014121532440186, array_map 0.0021569728851318
Output for 5.6.15
foreach 0.0011169910430908, array_walk 0.0015048980712891, array_map 0.0021309852600098
Output for 5.6.14
foreach 0.0018320083618164, array_walk 0.0022659301757812, array_map 0.0034308433532715
Output for 5.6.13
foreach 0.0016670227050781, array_walk 0.0017678737640381, array_map 0.0024871826171875
Output for 5.6.12
foreach 0.0014729499816895, array_walk 0.0021018981933594, array_map 0.0030448436737061
Output for 5.6.11
foreach 0.0018899440765381, array_walk 0.0023889541625977, array_map 0.0035750865936279
Output for 5.6.10
foreach 0.0019798278808594, array_walk 0.0028040409088135, array_map 0.0033440589904785
Output for 5.6.9
foreach 0.0012350082397461, array_walk 0.0016360282897949, array_map 0.0024828910827637
Output for 5.6.8
foreach 0.001121997833252, array_walk 0.0014550685882568, array_map 0.0022151470184326
Output for 5.6.7
foreach 0.0015909671783447, array_walk 0.001917839050293, array_map 0.0029540061950684
Output for 5.6.6
foreach 0.0017011165618896, array_walk 0.0021929740905762, array_map 0.0032331943511963
Output for 5.6.5
foreach 0.001615047454834, array_walk 0.0015590190887451, array_map 0.0035219192504883
Output for 5.6.4
foreach 0.0018310546875, array_walk 0.0022850036621094, array_map 0.0034890174865723
Output for 5.6.3
foreach 0.0016300678253174, array_walk 0.0019900798797607, array_map 0.003087043762207
Output for 5.6.2
foreach 0.0018320083618164, array_walk 0.0024008750915527, array_map 0.003547191619873
Output for 5.6.1
foreach 0.0019512176513672, array_walk 0.0021090507507324, array_map 0.0033471584320068
Output for 5.6.0
foreach 0.0016679763793945, array_walk 0.0021481513977051, array_map 0.0032298564910889
Output for 5.5.38
foreach 0.0016169548034668, array_walk 0.0018820762634277, array_map 0.0030372142791748
Output for 5.5.37
foreach 0.0018460750579834, array_walk 0.0022501945495605, array_map 0.0035679340362549
Output for 5.5.36
foreach 0.001345157623291, array_walk 0.0016112327575684, array_map 0.0025160312652588
Output for 5.5.35
foreach 0.0025150775909424, array_walk 0.0015730857849121, array_map 0.0024330615997314
Output for 5.5.34
foreach 0.0019102096557617, array_walk 0.002410888671875, array_map 0.0035049915313721
Output for 5.5.33
foreach 0.0014832019805908, array_walk 0.0017859935760498, array_map 0.0028510093688965
Output for 5.5.32
foreach 0.0016379356384277, array_walk 0.0019309520721436, array_map 0.0030810832977295
Output for 5.5.31
foreach 0.0016319751739502, array_walk 0.0018730163574219, array_map 0.002964973449707
Output for 5.5.30
foreach 0.0011091232299805, array_walk 0.0013761520385742, array_map 0.0021350383758545
Output for 5.5.29
foreach 0.0018808841705322, array_walk 0.0022799968719482, array_map 0.0036258697509766
Output for 5.5.28
foreach 0.0019309520721436, array_walk 0.0015249252319336, array_map 0.0036718845367432
Output for 5.5.27
foreach 0.001784086227417, array_walk 0.002249002456665, array_map 0.0035510063171387
Output for 5.5.26
foreach 0.001755952835083, array_walk 0.0021328926086426, array_map 0.0027861595153809
Output for 5.5.25
foreach 0.0016469955444336, array_walk 0.0018899440765381, array_map 0.0029909610748291
Output for 5.5.24
foreach 0.0018248558044434, array_walk 0.002392053604126, array_map 0.0035679340362549
Output for 5.5.23
foreach 0.0015771389007568, array_walk 0.001823902130127, array_map 0.0029008388519287
Output for 5.5.22
foreach 0.0013549327850342, array_walk 0.0015091896057129, array_map 0.0021421909332275
Output for 5.5.21
foreach 0.0017099380493164, array_walk 0.0019350051879883, array_map 0.0031309127807617
Output for 5.5.20
foreach 0.0018661022186279, array_walk 0.0021481513977051, array_map 0.0034158229827881
Output for 5.5.19
foreach 0.0012969970703125, array_walk 0.0016179084777832, array_map 0.0025739669799805
Output for 5.5.18
foreach 0.0018761157989502, array_walk 0.0021450519561768, array_map 0.0034358501434326
Output for 5.5.16
foreach 0.0015878677368164, array_walk 0.0018999576568604, array_map 0.00301194190979
Output for 5.5.15
foreach 0.0016319751739502, array_walk 0.0020132064819336, array_map 0.0030770301818848
Output for 5.5.14
foreach 0.0018429756164551, array_walk 0.0018918514251709, array_map 0.0029799938201904
Output for 5.5.13
foreach 0.0018119812011719, array_walk 0.0022530555725098, array_map 0.0030369758605957
Output for 5.5.12
foreach 0.0017590522766113, array_walk 0.0020310878753662, array_map 0.0031318664550781
Output for 5.5.11
foreach 0.003004789352417, array_walk 0.0034818649291992, array_map 0.0058219432830811
Output for 5.5.10
foreach 0.0018060207366943, array_walk 0.0022270679473877, array_map 0.0035369396209717
Output for 5.5.9
foreach 0.0013749599456787, array_walk 0.0016589164733887, array_map 0.0025808811187744
Output for 5.5.8
foreach 0.0017471313476562, array_walk 0.0021581649780273, array_map 0.0032408237457275
Output for 5.5.7
foreach 0.001845121383667, array_walk 0.0023097991943359, array_map 0.0035929679870605
Output for 5.5.6
foreach 0.0018148422241211, array_walk 0.002032995223999, array_map 0.0027999877929688
Output for 5.5.5
foreach 0.0017678737640381, array_walk 0.002108097076416, array_map 0.0032799243927002
Output for 5.5.4
foreach 0.0015020370483398, array_walk 0.0015888214111328, array_map 0.0038480758666992
Output for 5.5.3
foreach 0.00177001953125, array_walk 0.0021121501922607, array_map 0.0034079551696777
Output for 5.5.2
foreach 0.0011398792266846, array_walk 0.001338005065918, array_map 0.002100944519043
Output for 5.5.1
foreach 0.0017368793487549, array_walk 0.0021159648895264, array_map 0.0035769939422607
Output for 5.5.0
foreach 0.0018529891967773, array_walk 0.0022640228271484, array_map 0.0034611225128174
Output for 5.4.45
foreach 0.0014760494232178, array_walk 0.0018110275268555, array_map 0.0026462078094482
Output for 5.4.44
foreach 0.0019290447235107, array_walk 0.002439022064209, array_map 0.0035841464996338
Output for 5.4.43
foreach 0.0015718936920166, array_walk 0.001945972442627, array_map 0.002953052520752
Output for 5.4.42
foreach 0.0018308162689209, array_walk 0.0021538734436035, array_map 0.003371000289917
Output for 5.4.41
foreach 0.0018761157989502, array_walk 0.0023651123046875, array_map 0.0036559104919434
Output for 5.4.40
foreach 0.0017969608306885, array_walk 0.0026650428771973, array_map 0.0036988258361816
Output for 5.4.39
foreach 0.0016500949859619, array_walk 0.0019769668579102, array_map 0.0031390190124512
Output for 5.4.38
foreach 0.0016970634460449, array_walk 0.0024309158325195, array_map 0.0029909610748291
Output for 5.4.37
foreach 0.0014750957489014, array_walk 0.0017199516296387, array_map 0.0027680397033691
Output for 5.4.36
foreach 0.0018818378448486, array_walk 0.0022180080413818, array_map 0.0034351348876953
Output for 5.4.35
foreach 0.0019669532775879, array_walk 0.0023701190948486, array_map 0.0037741661071777
Output for 5.4.34
foreach 0.0017070770263672, array_walk 0.0020558834075928, array_map 0.002626895904541
Output for 5.4.32
foreach 0.001971960067749, array_walk 0.0021779537200928, array_map 0.0034680366516113
Output for 5.4.31
foreach 0.0019598007202148, array_walk 0.0022461414337158, array_map 0.003544807434082
Output for 5.4.30
foreach 0.0014340877532959, array_walk 0.0017709732055664, array_map 0.0027501583099365
Output for 5.4.29
foreach 0.0016000270843506, array_walk 0.0014758110046387, array_map 0.0022661685943604
Output for 5.4.28
foreach 0.0017678737640381, array_walk 0.0022220611572266, array_map 0.0033180713653564
Output for 5.4.27
foreach 0.0028939247131348, array_walk 0.0032351016998291, array_map 0.0029540061950684
Output for 5.4.26
foreach 0.0025138854980469, array_walk 0.0029659271240234, array_map 0.0031089782714844
Output for 5.4.25
foreach 0.0013988018035889, array_walk 0.0013821125030518, array_map 0.0021519660949707
Output for 5.4.24
foreach 0.0019741058349609, array_walk 0.0021891593933105, array_map 0.0031428337097168
Output for 5.4.23
foreach 0.0036048889160156, array_walk 0.0038340091705322, array_map 0.0062191486358643
Output for 5.4.22
foreach 0.0019140243530273, array_walk 0.0016651153564453, array_map 0.0030748844146729
Output for 5.4.21
foreach 0.0016510486602783, array_walk 0.0019690990447998, array_map 0.0030069351196289
Output for 5.4.20
foreach 0.0016701221466064, array_walk 0.002263069152832, array_map 0.0032069683074951
Output for 5.4.19
foreach 0.0019199848175049, array_walk 0.0022671222686768, array_map 0.0034530162811279
Output for 5.4.18
foreach 0.0017349720001221, array_walk 0.0020310878753662, array_map 0.0031888484954834
Output for 5.4.17
foreach 0.0018310546875, array_walk 0.00211501121521, array_map 0.0033459663391113
Output for 5.4.16
foreach 0.0019540786743164, array_walk 0.002147912979126, array_map 0.0032658576965332
Output for 5.4.15
foreach 0.0011510848999023, array_walk 0.0013258457183838, array_map 0.0020771026611328
Output for 5.4.14
foreach 0.0019509792327881, array_walk 0.002345085144043, array_map 0.0036599636077881
Output for 5.4.13
foreach 0.0019528865814209, array_walk 0.0022401809692383, array_map 0.0042078495025635
Output for 5.4.12
foreach 0.0020790100097656, array_walk 0.0023608207702637, array_map 0.0036110877990723
Output for 5.4.11
foreach 0.0017712116241455, array_walk 0.0018370151519775, array_map 0.0025601387023926
Output for 5.4.10
foreach 0.0017318725585938, array_walk 0.0020120143890381, array_map 0.0032131671905518
Output for 5.4.9
foreach 0.0013289451599121, array_walk 0.0017910003662109, array_map 0.0026519298553467
Output for 5.4.8
foreach 0.0013830661773682, array_walk 0.0016140937805176, array_map 0.0025098323822021
Output for 5.4.7
foreach 0.0011751651763916, array_walk 0.0013580322265625, array_map 0.0038859844207764
Output for 5.4.6
foreach 0.0026640892028809, array_walk 0.0016608238220215, array_map 0.0025639533996582
Output for 5.4.5
foreach 0.002000093460083, array_walk 0.0022871494293213, array_map 0.0035221576690674
Output for 5.4.4
foreach 0.0019330978393555, array_walk 0.0021519660949707, array_map 0.0035450458526611
Output for 5.4.3
foreach 0.0019640922546387, array_walk 0.0021989345550537, array_map 0.0035040378570557
Output for 5.4.2
foreach 0.0014870166778564, array_walk 0.0016739368438721, array_map 0.0027709007263184
Output for 5.4.1
foreach 0.0017797946929932, array_walk 0.0020999908447266, array_map 0.0035140514373779
Output for 5.4.0
foreach 0.0018579959869385, array_walk 0.0022599697113037, array_map 0.0032949447631836
Output for 5.3.29
foreach 0.0018410682678223, array_walk 0.001939058303833, array_map 0.0029451847076416
Output for 5.3.28
foreach 0.0020589828491211, array_walk 0.0022039413452148, array_map 0.0031099319458008
Output for 5.3.27
foreach 0.0013129711151123, array_walk 0.0015068054199219, array_map 0.0022711753845215
Output for 5.3.26
foreach 0.0019340515136719, array_walk 0.0020689964294434, array_map 0.003061056137085
Output for 5.3.25
foreach 0.0017960071563721, array_walk 0.0019690990447998, array_map 0.002938985824585
Output for 5.3.24
foreach 0.0022239685058594, array_walk 0.0024170875549316, array_map 0.0035021305084229
Output for 5.3.23
foreach 0.0019440650939941, array_walk 0.0020542144775391, array_map 0.0030949115753174
Output for 5.3.22
foreach 0.0022039413452148, array_walk 0.0024640560150146, array_map 0.0037400722503662
Output for 5.3.21
foreach 0.0021719932556152, array_walk 0.0016829967498779, array_map 0.0022637844085693
Output for 5.3.20
foreach 0.0020678043365479, array_walk 0.0022881031036377, array_map 0.0034441947937012
Output for 5.3.19
foreach 0.0017168521881104, array_walk 0.0019099712371826, array_map 0.0028939247131348
Output for 5.3.18
foreach 0.001582145690918, array_walk 0.0017452239990234, array_map 0.0027101039886475
Output for 5.3.17
foreach 0.0018210411071777, array_walk 0.002079963684082, array_map 0.003242015838623
Output for 5.3.16
foreach 0.0020790100097656, array_walk 0.0022950172424316, array_map 0.0033681392669678
Output for 5.3.15
foreach 0.0023050308227539, array_walk 0.002479076385498, array_map 0.0036461353302002
Output for 5.3.14
foreach 0.0020530223846436, array_walk 0.0022859573364258, array_map 0.0033729076385498
Output for 5.3.13
foreach 0.0015869140625, array_walk 0.0015389919281006, array_map 0.0035281181335449
Output for 5.3.12
foreach 0.0017998218536377, array_walk 0.0019569396972656, array_map 0.0025138854980469
Output for 5.3.11
foreach 0.0021870136260986, array_walk 0.0022568702697754, array_map 0.0033230781555176
Output for 5.3.10
foreach 0.0021770000457764, array_walk 0.0025160312652588, array_map 0.0035748481750488
Output for 5.3.9
foreach 0.0017750263214111, array_walk 0.0019190311431885, array_map 0.0028529167175293
Output for 5.3.8
foreach 0.002263069152832, array_walk 0.0024099349975586, array_map 0.0036840438842773
Output for 5.3.7
foreach 0.0020678043365479, array_walk 0.0024089813232422, array_map 0.0035610198974609
Output for 5.3.6
foreach 0.0021579265594482, array_walk 0.0022299289703369, array_map 0.0033190250396729
Output for 5.3.5
foreach 0.0022628307342529, array_walk 0.0024828910827637, array_map 0.00364089012146
Output for 5.3.4
foreach 0.0014989376068115, array_walk 0.0016360282897949, array_map 0.0023138523101807
Output for 5.3.3
foreach 0.0015780925750732, array_walk 0.0017459392547607, array_map 0.0026559829711914
Output for 5.3.2
foreach 0.0013360977172852, array_walk 0.001500129699707, array_map 0.0023047924041748
Output for 5.3.1
foreach 0.0022790431976318, array_walk 0.0024771690368652, array_map 0.0037269592285156
Output for 5.3.0
foreach 0.002720832824707, array_walk 0.002734899520874, array_map 0.0044801235198975
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/7F55J 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/7F55J on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/7F55J on line 5
Process exited with code 255.