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); } echo ', array_map '.(microtime(true) - $t);
Output for 7.1.0
foreach 0.00049090385437012, array_walk 0.00066685676574707, array_map 0.00055599212646484
Output for 7.0.14
foreach 0.00064396858215332, array_walk 0.00075101852416992, array_map 0.00074100494384766
Output for 7.0.6
foreach 0.00037002563476562, array_walk 0.00061702728271484, array_map 0.00062322616577148
Output for 7.0.5
foreach 0.00039482116699219, array_walk 0.00066614151000977, array_map 0.0006871223449707
Output for 7.0.4
foreach 0.00043702125549316, array_walk 0.00076389312744141, array_map 0.00072789192199707
Output for 7.0.3
foreach 0.00037288665771484, array_walk 0.0006411075592041, array_map 0.00063610076904297
Output for 7.0.2
foreach 0.00041103363037109, array_walk 0.0006861686706543, array_map 0.00067996978759766
Output for 7.0.1
foreach 0.0004889965057373, array_walk 0.0008089542388916, array_map 0.00077295303344727
Output for 7.0.0
foreach 0.00058412551879883, array_walk 0.00097107887268066, array_map 0.0010280609130859
Output for 5.6.28
foreach 0.0022549629211426, array_walk 0.0024330615997314, array_map 0.0031759738922119
Output for 5.6.21
foreach 0.0018079280853271, array_walk 0.0023159980773926, array_map 0.0030350685119629
Output for 5.6.20
foreach 0.0011091232299805, array_walk 0.0014221668243408, array_map 0.0018100738525391
Output for 5.6.19
foreach 0.0012569427490234, array_walk 0.0015149116516113, array_map 0.0019741058349609
Output for 5.6.18
foreach 0.0017561912536621, array_walk 0.0019650459289551, array_map 0.0026180744171143
Output for 5.6.17
foreach 0.0011320114135742, array_walk 0.001378059387207, array_map 0.0018041133880615
Output for 5.6.16
foreach 0.0013918876647949, array_walk 0.0017020702362061, array_map 0.0021231174468994
Output for 5.6.15
foreach 0.0015261173248291, array_walk 0.0019481182098389, array_map 0.0025010108947754
Output for 5.6.14
foreach 0.0018031597137451, array_walk 0.0022130012512207, array_map 0.0029239654541016
Output for 5.6.13
foreach 0.0012199878692627, array_walk 0.0015177726745605, array_map 0.0019550323486328
Output for 5.6.12
foreach 0.0010910034179688, array_walk 0.0014009475708008, array_map 0.0018310546875
Output for 5.6.11
foreach 0.0014951229095459, array_walk 0.0017890930175781, array_map 0.0022058486938477
Output for 5.6.10
foreach 0.0018260478973389, array_walk 0.0019881725311279, array_map 0.0025250911712646
Output for 5.6.9
foreach 0.0017611980438232, array_walk 0.0021610260009766, array_map 0.0027210712432861
Output for 5.6.8
foreach 0.0013301372528076, array_walk 0.0016920566558838, array_map 0.0023679733276367
Output for 5.5.35
foreach 0.00093889236450195, array_walk 0.0011160373687744, array_map 0.0014920234680176
Output for 5.5.34
foreach 0.0017750263214111, array_walk 0.0021188259124756, array_map 0.0028009414672852
Output for 5.5.33
foreach 0.0011250972747803, array_walk 0.0019268989562988, array_map 0.0018489360809326
Output for 5.5.32
foreach 0.0016360282897949, array_walk 0.0018258094787598, array_map 0.0023829936981201
Output for 5.5.31
foreach 0.0016419887542725, array_walk 0.0019509792327881, array_map 0.0025229454040527
Output for 5.5.30
foreach 0.0017678737640381, array_walk 0.0021669864654541, array_map 0.0028409957885742
Output for 5.5.29
foreach 0.0018532276153564, array_walk 0.0021350383758545, array_map 0.0030930042266846
Output for 5.5.28
foreach 0.0015921592712402, array_walk 0.0018248558044434, array_map 0.0024650096893311
Output for 5.5.27
foreach 0.0016438961029053, array_walk 0.0019540786743164, array_map 0.0024430751800537
Output for 5.5.26
foreach 0.0011608600616455, array_walk 0.0013461112976074, array_map 0.0017580986022949
Output for 5.5.25
foreach 0.0018279552459717, array_walk 0.0021731853485107, array_map 0.0027890205383301
Output for 5.5.24
foreach 0.0011191368103027, array_walk 0.0013370513916016, array_map 0.001762866973877
Output for 5.4.45
foreach 0.0011670589447021, array_walk 0.0014798641204834, array_map 0.0019519329071045
Output for 5.4.44
foreach 0.0011579990386963, array_walk 0.0013439655303955, array_map 0.00177001953125
Output for 5.4.43
foreach 0.001154899597168, array_walk 0.0014011859893799, array_map 0.0018000602722168
Output for 5.4.42
foreach 0.0011529922485352, array_walk 0.0014078617095947, array_map 0.0017781257629395
Output for 5.4.41
foreach 0.0011451244354248, array_walk 0.0013811588287354, array_map 0.0017960071563721
Output for 5.4.40
foreach 0.0013768672943115, array_walk 0.0015509128570557, array_map 0.0023550987243652
Output for 5.4.39
foreach 0.0011770725250244, array_walk 0.0013329982757568, array_map 0.0017518997192383
Output for 5.4.38
foreach 0.0011451244354248, array_walk 0.0013561248779297, array_map 0.0017969608306885
Output for 5.4.37
foreach 0.0018000602722168, array_walk 0.0021119117736816, array_map 0.0028359889984131
Output for 5.4.36
foreach 0.0017688274383545, array_walk 0.0021028518676758, array_map 0.0027358531951904
Output for 5.4.35
foreach 0.0018219947814941, array_walk 0.001878023147583, array_map 0.002399206161499
Output for 5.4.34
foreach 0.0011589527130127, array_walk 0.0013270378112793, array_map 0.0018010139465332
Output for 5.4.32
foreach 0.0011501312255859, array_walk 0.001323938369751, array_map 0.0017340183258057
Output for 5.4.31
foreach 0.0011379718780518, array_walk 0.0013258457183838, array_map 0.0017409324645996
Output for 5.4.30
foreach 0.0011420249938965, array_walk 0.0014009475708008, array_map 0.0018119812011719
Output for 5.4.29
foreach 0.0011789798736572, array_walk 0.0013771057128906, array_map 0.001816987991333
Output for 5.4.28
foreach 0.0011568069458008, array_walk 0.0013740062713623, array_map 0.0017869472503662
Output for 5.4.27
foreach 0.0011470317840576, array_walk 0.0013740062713623, array_map 0.0017712116241455
Output for 5.4.26
foreach 0.0011460781097412, array_walk 0.0013492107391357, array_map 0.0017631053924561
Output for 5.4.25
foreach 0.0011370182037354, array_walk 0.0013728141784668, array_map 0.0017719268798828
Output for 5.4.24
foreach 0.0011501312255859, array_walk 0.0013549327850342, array_map 0.0018060207366943
Output for 5.4.23
foreach 0.0012600421905518, array_walk 0.0013828277587891, array_map 0.0020298957824707
Output for 5.4.22
foreach 0.0011799335479736, array_walk 0.001572847366333, array_map 0.0017540454864502
Output for 5.4.21
foreach 0.0011491775512695, array_walk 0.0013570785522461, array_map 0.0022580623626709
Output for 5.4.20
foreach 0.0014700889587402, array_walk 0.0018291473388672, array_map 0.0022919178009033
Output for 5.4.19
foreach 0.0011501312255859, array_walk 0.0013289451599121, array_map 0.0017900466918945
Output for 5.4.18
foreach 0.0011579990386963, array_walk 0.0013449192047119, array_map 0.0017910003662109
Output for 5.4.17
foreach 0.0011739730834961, array_walk 0.0013570785522461, array_map 0.0017871856689453
Output for 5.4.16
foreach 0.0011560916900635, array_walk 0.0013489723205566, array_map 0.0017449855804443
Output for 5.4.15
foreach 0.0011720657348633, array_walk 0.0013399124145508, array_map 0.00177001953125
Output for 5.4.14
foreach 0.0011241436004639, array_walk 0.0013420581817627, array_map 0.0017781257629395
Output for 5.4.13
foreach 0.0011539459228516, array_walk 0.0014281272888184, array_map 0.0018570423126221
Output for 5.4.12
foreach 0.001129150390625, array_walk 0.001413106918335, array_map 0.0017490386962891
Output for 5.4.11
foreach 0.0019471645355225, array_walk 0.0021810531616211, array_map 0.0027749538421631
Output for 5.4.10
foreach 0.0019290447235107, array_walk 0.0029370784759521, array_map 0.0027189254760742
Output for 5.4.9
foreach 0.0043110847473145, array_walk 0.0049030780792236, array_map 0.005789041519165
Output for 5.4.8
foreach 0.0011241436004639, array_walk 0.001331090927124, array_map 0.0017521381378174
Output for 5.4.7
foreach 0.0012168884277344, array_walk 0.0013260841369629, array_map 0.0017948150634766
Output for 5.4.6
foreach 0.0011389255523682, array_walk 0.0013120174407959, array_map 0.0017380714416504
Output for 5.4.5
foreach 0.0011398792266846, array_walk 0.0012938976287842, array_map 0.0017578601837158
Output for 5.4.4
foreach 0.0015549659729004, array_walk 0.00164794921875, array_map 0.002392053604126
Output for 5.4.3
foreach 0.0011129379272461, array_walk 0.0013539791107178, array_map 0.0017900466918945
Output for 5.4.2
foreach 0.0011489391326904, array_walk 0.0013339519500732, array_map 0.0018010139465332
Output for 5.4.1
foreach 0.0011401176452637, array_walk 0.0013470649719238, array_map 0.0018157958984375
Output for 5.4.0
foreach 0.0010879039764404, array_walk 0.0013790130615234, array_map 0.0017399787902832
Output for 5.3.29
foreach 0.0013289451599121, array_walk 0.0014078617095947, array_map 0.0018081665039062
Output for 5.3.28
foreach 0.0012989044189453, array_walk 0.0014379024505615, array_map 0.0017881393432617
Output for 5.3.27
foreach 0.001305103302002, array_walk 0.0014188289642334, array_map 0.0018219947814941
Output for 5.3.26
foreach 0.0013079643249512, array_walk 0.0014321804046631, array_map 0.0017931461334229
Output for 5.3.25
foreach 0.0013251304626465, array_walk 0.0013928413391113, array_map 0.0018000602722168
Output for 5.3.24
foreach 0.0013799667358398, array_walk 0.001392126083374, array_map 0.0017988681793213
Output for 5.3.23
foreach 0.0013651847839355, array_walk 0.0014729499816895, array_map 0.0019068717956543
Output for 5.3.22
foreach 0.0013189315795898, array_walk 0.0014948844909668, array_map 0.001863956451416
Output for 5.3.21
foreach 0.0013229846954346, array_walk 0.0015439987182617, array_map 0.0019218921661377
Output for 5.3.20
foreach 0.0013110637664795, array_walk 0.0014340877532959, array_map 0.0018219947814941
Output for 5.3.19
foreach 0.0013508796691895, array_walk 0.0014290809631348, array_map 0.0018479824066162
Output for 5.3.18
foreach 0.0013079643249512, array_walk 0.0014269351959229, array_map 0.0018320083618164
Output for 5.3.17
foreach 0.0012969970703125, array_walk 0.0014550685882568, array_map 0.0018022060394287
Output for 5.3.16
foreach 0.0012891292572021, array_walk 0.0014019012451172, array_map 0.001774787902832
Output for 5.3.15
foreach 0.0012822151184082, array_walk 0.0014259815216064, array_map 0.002032995223999
Output for 5.3.14
foreach 0.0013358592987061, array_walk 0.0014472007751465, array_map 0.0018329620361328
Output for 5.3.13
foreach 0.0013201236724854, array_walk 0.0014691352844238, array_map 0.0018191337585449
Output for 5.3.12
foreach 0.0013108253479004, array_walk 0.0014820098876953, array_map 0.0018160343170166
Output for 5.3.11
foreach 0.0013298988342285, array_walk 0.0015451908111572, array_map 0.0019028186798096
Output for 5.3.10
foreach 0.0012879371643066, array_walk 0.0014820098876953, array_map 0.0018401145935059
Output for 5.3.9
foreach 0.0013160705566406, array_walk 0.0014221668243408, array_map 0.001845121383667
Output for 5.3.8
foreach 0.001317024230957, array_walk 0.0014188289642334, array_map 0.0018310546875
Output for 5.3.7
foreach 0.0016250610351562, array_walk 0.0023012161254883, array_map 0.0031321048736572
Output for 5.3.6
foreach 0.00130295753479, array_walk 0.0015261173248291, array_map 0.0019400119781494
Output for 5.3.5
foreach 0.0014419555664062, array_walk 0.0017900466918945, array_map 0.0025990009307861
Output for 5.3.4
foreach 0.0013148784637451, array_walk 0.0014231204986572, array_map 0.0018491744995117
Output for 5.3.3
foreach 0.0025920867919922, array_walk 0.0019159317016602, array_map 0.0024890899658203
Output for 5.3.2
foreach 0.0013020038604736, array_walk 0.0014848709106445, array_map 0.0018560886383057
Output for 5.3.1
foreach 0.0013470649719238, array_walk 0.001474142074585, array_map 0.0018260478973389
Output for 5.3.0
foreach 0.0013620853424072, array_walk 0.0014338493347168, array_map 0.0018379688262939
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/oD3lt 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/oD3lt on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/oD3lt on line 5
Process exited with code 255.