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).'\n';
Output for 7.1.0
foreach: 0.00075101852416992, array_walk: 0.00091695785522461, array_map: 0.00089907646179199\n
Output for 7.0.14
foreach: 0.00063800811767578, array_walk: 0.00081300735473633, array_map: 0.00090312957763672\n
Output for 7.0.12
foreach: 0.0006871223449707, array_walk: 0.00081992149353027, array_map: 0.00088715553283691\n
Output for 7.0.11
foreach: 0.0006251335144043, array_walk: 0.00072813034057617, array_map: 0.00077605247497559\n
Output for 7.0.10
foreach: 0.00057888031005859, array_walk: 0.00067615509033203, array_map: 0.00088691711425781\n
Output for 7.0.9
foreach: 0.0007021427154541, array_walk: 0.00077295303344727, array_map: 0.00082683563232422\n
Output for 7.0.8
foreach: 0.00067996978759766, array_walk: 0.00078201293945312, array_map: 0.00087618827819824\n
Output for 7.0.7
foreach: 0.00068497657775879, array_walk: 0.00085616111755371, array_map: 0.00091218948364258\n
Output for 7.0.6
foreach: 0.00069284439086914, array_walk: 0.0011920928955078, array_map: 0.0012919902801514\n
Output for 7.0.5
foreach: 0.00064611434936523, array_walk: 0.00118088722229, array_map: 0.0012650489807129\n
Output for 7.0.4
foreach: 0.00064897537231445, array_walk: 0.0012030601501465, array_map: 0.00130295753479\n
Output for 7.0.3
foreach: 0.00078916549682617, array_walk: 0.001190185546875, array_map: 0.0012149810791016\n
Output for 7.0.2
foreach: 0.00089311599731445, array_walk: 0.0012710094451904, array_map: 0.0013370513916016\n
Output for 7.0.1
foreach: 0.00076198577880859, array_walk: 0.0011160373687744, array_map: 0.0012040138244629\n
Output for 7.0.0
foreach: 0.00060701370239258, array_walk: 0.001107931137085, array_map: 0.0012037754058838\n
Output for 5.6.28
foreach: 0.0022251605987549, array_walk: 0.0024130344390869, array_map: 0.003899097442627\n
Output for 5.6.26
foreach: 0.0024740695953369, array_walk: 0.0024361610412598, array_map: 0.0037961006164551\n
Output for 5.6.25
foreach: 0.0023210048675537, array_walk: 0.0024490356445312, array_map: 0.0038490295410156\n
Output for 5.6.24
foreach: 0.0020098686218262, array_walk: 0.002108097076416, array_map: 0.0033440589904785\n
Output for 5.6.23
foreach: 0.0019559860229492, array_walk: 0.002457857131958, array_map: 0.0038199424743652\n
Output for 5.6.22
foreach: 0.0019268989562988, array_walk: 0.0024750232696533, array_map: 0.0038979053497314\n
Output for 5.6.21
foreach: 0.0021629333496094, array_walk: 0.0024800300598145, array_map: 0.0036311149597168\n
Output for 5.6.20
foreach: 0.0020220279693604, array_walk: 0.0024070739746094, array_map: 0.00370192527771\n
Output for 5.6.19
foreach: 0.0020608901977539, array_walk: 0.0023078918457031, array_map: 0.0035841464996338\n
Output for 5.6.18
foreach: 0.0020360946655273, array_walk: 0.0024330615997314, array_map: 0.0038020610809326\n
Output for 5.6.17
foreach: 0.0018119812011719, array_walk: 0.0024230480194092, array_map: 0.0037240982055664\n
Output for 5.6.16
foreach: 0.0024800300598145, array_walk: 0.0030300617218018, array_map: 0.0047130584716797\n
Output for 5.6.15
foreach: 0.0020089149475098, array_walk: 0.0023980140686035, array_map: 0.003809928894043\n
Output for 5.6.14
foreach: 0.00217604637146, array_walk: 0.0023441314697266, array_map: 0.0036439895629883\n
Output for 5.6.13
foreach: 0.0019190311431885, array_walk: 0.0023858547210693, array_map: -0.017297983169556\n
Output for 5.6.12
foreach: 0.0020320415496826, array_walk: 0.0022811889648438, array_map: 0.0034101009368896\n
Output for 5.6.11
foreach: 0.0018711090087891, array_walk: 0.0022900104522705, array_map: 0.0036849975585938\n
Output for 5.6.10
foreach: 0.0018980503082275, array_walk: 0.0022819042205811, array_map: 0.0036160945892334\n
Output for 5.6.9
foreach: 0.0014939308166504, array_walk: 0.0018649101257324, array_map: 0.0029799938201904\n
Output for 5.6.8
foreach: 0.0019071102142334, array_walk: 0.0022480487823486, array_map: 0.0036089420318604\n
Output for 5.6.7
foreach: 0.0019681453704834, array_walk: 0.0023338794708252, array_map: 0.0038189888000488\n
Output for 5.6.6
foreach: 0.0015058517456055, array_walk: 0.0020890235900879, array_map: 0.0029242038726807\n
Output for 5.6.5
foreach: 0.0020959377288818, array_walk: 0.0023880004882812, array_map: 0.0038559436798096\n
Output for 5.6.4
foreach: 0.0019450187683105, array_walk: 0.0023880004882812, array_map: 0.0038061141967773\n
Output for 5.6.3
foreach: 0.0019180774688721, array_walk: 0.0024168491363525, array_map: 0.0038471221923828\n
Output for 5.6.2
foreach: 0.0012218952178955, array_walk: 0.0014839172363281, array_map: 0.0022439956665039\n
Output for 5.6.1
foreach: 0.0010569095611572, array_walk: 0.0012831687927246, array_map: 0.0022320747375488\n
Output for 5.6.0
foreach: 0.00177001953125, array_walk: 0.0020480155944824, array_map: 0.0032439231872559\n
Output for 5.5.38
foreach: 0.002453088760376, array_walk: 0.002277135848999, array_map: 0.0036940574645996\n
Output for 5.5.37
foreach: 0.0021939277648926, array_walk: 0.0022611618041992, array_map: 0.0037260055541992\n
Output for 5.5.36
foreach: 0.0019631385803223, array_walk: 0.0022881031036377, array_map: 0.0034079551696777\n
Output for 5.5.35
foreach: 0.0021867752075195, array_walk: 0.002295970916748, array_map: 0.0036711692810059\n
Output for 5.5.34
foreach: 0.0024008750915527, array_walk: 0.0026378631591797, array_map: 0.0040910243988037\n
Output for 5.5.33
foreach: 0.0028960704803467, array_walk: 0.0026910305023193, array_map: 0.0040361881256104\n
Output for 5.5.32
foreach: -0.007580041885376, array_walk: 0.0026230812072754, array_map: 0.0040271282196045\n
Output for 5.5.31
foreach: 0.0021171569824219, array_walk: 0.0022950172424316, array_map: 0.0033831596374512\n
Output for 5.5.30
foreach: 0.0024919509887695, array_walk: 0.0028419494628906, array_map: 0.0039739608764648\n
Output for 5.5.29
foreach: 0.0027458667755127, array_walk: 0.0022869110107422, array_map: 0.0035500526428223\n
Output for 5.5.28
foreach: 0.0025880336761475, array_walk: 0.0024721622467041, array_map: 0.0038268566131592\n
Output for 5.5.27
foreach: 0.0024328231811523, array_walk: 0.0025320053100586, array_map: 0.0037779808044434\n
Output for 5.5.26
foreach: 0.0023958683013916, array_walk: 0.0025639533996582, array_map: 0.0039710998535156\n
Output for 5.5.25
foreach: 0.0021109580993652, array_walk: 0.002410888671875, array_map: 0.0036101341247559\n
Output for 5.5.24
foreach: 0.0025119781494141, array_walk: 0.0026278495788574, array_map: 0.0040168762207031\n
Output for 5.5.23
foreach: 0.0023219585418701, array_walk: 0.0024371147155762, array_map: 0.0036318302154541\n
Output for 5.5.22
foreach: 0.0016529560089111, array_walk: 0.0017049312591553, array_map: 0.0026440620422363\n
Output for 5.5.21
foreach: 0.001305103302002, array_walk: 0.0013320446014404, array_map: 0.0020670890808105\n
Output for 5.5.20
foreach: 0.0027549266815186, array_walk: 0.0026791095733643, array_map: 0.0040168762207031\n
Output for 5.5.19
foreach: 0.0025849342346191, array_walk: 0.0024240016937256, array_map: 0.0037980079650879\n
Output for 5.5.18
foreach: 0.0023500919342041, array_walk: 0.0025579929351807, array_map: 0.0037009716033936\n
Output for 5.5.16
foreach: 0.0025999546051025, array_walk: 0.0025911331176758, array_map: 0.0040309429168701\n
Output for 5.5.15
foreach: 0.002331018447876, array_walk: 0.0023210048675537, array_map: 0.0037178993225098\n
Output for 5.5.14
foreach: 0.001788854598999, array_walk: 0.0020120143890381, array_map: 0.0030298233032227\n
Output for 5.5.13
foreach: 0.001600980758667, array_walk: 0.0015499591827393, array_map: 0.0024039745330811\n
Output for 5.5.12
foreach: 0.0014660358428955, array_walk: 0.001338005065918, array_map: 0.0020780563354492\n
Output for 5.5.11
foreach: 0.0020182132720947, array_walk: 0.0022389888763428, array_map: 0.0032529830932617\n
Output for 5.5.10
foreach: 0.0022208690643311, array_walk: 0.010462045669556, array_map: 0.0052740573883057\n
Output for 5.5.9
foreach: 0.0018770694732666, array_walk: 0.0020401477813721, array_map: 0.003093957901001\n
Output for 5.5.8
foreach: 0.0024888515472412, array_walk: 0.0026681423187256, array_map: 0.0040879249572754\n
Output for 5.5.7
foreach: 0.0024228096008301, array_walk: 0.0024631023406982, array_map: 0.0037639141082764\n
Output for 5.5.6
foreach: 0.0026991367340088, array_walk: 0.0025990009307861, array_map: 0.004004955291748\n
Output for 5.5.5
foreach: 0.0022480487823486, array_walk: 0.0025150775909424, array_map: 0.0037920475006104\n
Output for 5.5.4
foreach: 0.0026369094848633, array_walk: 0.0029110908508301, array_map: 0.0043020248413086\n
Output for 5.5.3
foreach: 0.0016248226165771, array_walk: 0.0015780925750732, array_map: 0.0024068355560303\n
Output for 5.5.2
foreach: 0.0024890899658203, array_walk: 0.0026810169219971, array_map: 0.0041348934173584\n
Output for 5.5.1
foreach: 0.0012919902801514, array_walk: 0.0013518333435059, array_map: 0.0021018981933594\n
Output for 5.5.0
foreach: 0.002871036529541, array_walk: 0.0027599334716797, array_map: 0.0039801597595215\n
Output for 5.4.45
foreach: 0.002432107925415, array_walk: 0.0022921562194824, array_map: 0.0035469532012939\n
Output for 5.4.44
foreach: 0.0026860237121582, array_walk: 0.0025930404663086, array_map: 0.0039751529693604\n
Output for 5.4.43
foreach: 0.0028140544891357, array_walk: 0.0025219917297363, array_map: 0.0038509368896484\n
Output for 5.4.42
foreach: 0.0024220943450928, array_walk: 0.0025479793548584, array_map: 0.0037119388580322\n
Output for 5.4.41
foreach: 0.0023629665374756, array_walk: 0.0023090839385986, array_map: 0.0036048889160156\n
Output for 5.4.40
foreach: 0.0028328895568848, array_walk: 0.0027000904083252, array_map: 0.0040669441223145\n
Output for 5.4.39
foreach: 0.0022931098937988, array_walk: 0.0021688938140869, array_map: 0.0033450126647949\n
Output for 5.4.38
foreach: 0.0023150444030762, array_walk: 0.0023579597473145, array_map: 0.0035572052001953\n
Output for 5.4.37
foreach: 0.0026199817657471, array_walk: 0.0025060176849365, array_map: 0.0038690567016602\n
Output for 5.4.36
foreach: 0.0024731159210205, array_walk: 0.0024411678314209, array_map: 0.0037598609924316\n
Output for 5.4.35
foreach: 0.0026369094848633, array_walk: 0.0026891231536865, array_map: 0.0040690898895264\n
Output for 5.4.34
foreach: 0.0013699531555176, array_walk: 0.0014629364013672, array_map: 0.0021507740020752\n
Output for 5.4.32
foreach: 0.0027391910552979, array_walk: 0.0026040077209473, array_map: 0.0040850639343262\n
Output for 5.4.31
foreach: 0.0021598339080811, array_walk: 0.002126932144165, array_map: 0.0032429695129395\n
Output for 5.4.30
foreach: 0.0029041767120361, array_walk: 0.0025129318237305, array_map: 0.0036540031433105\n
Output for 5.4.29
foreach: 0.0013589859008789, array_walk: 0.0013821125030518, array_map: 0.0021028518676758\n
Output for 5.4.28
foreach: 0.0014209747314453, array_walk: 0.001507043838501, array_map: 0.002263069152832\n
Output for 5.4.27
foreach: 0.0018050670623779, array_walk: 0.0018789768218994, array_map: 0.0028600692749023\n
Output for 5.4.26
foreach: 0.0026051998138428, array_walk: 0.0023469924926758, array_map: 0.0036730766296387\n
Output for 5.4.25
foreach: 0.0025231838226318, array_walk: 0.0025069713592529, array_map: 0.003849983215332\n
Output for 5.4.24
foreach: 0.0022280216217041, array_walk: 0.0022201538085938, array_map: 0.0033230781555176\n
Output for 5.4.23
foreach: 0.002418041229248, array_walk: 0.0026469230651855, array_map: 0.0038549900054932\n
Output for 5.4.22
foreach: 0.0025589466094971, array_walk: 0.0026500225067139, array_map: 0.0039219856262207\n
Output for 5.4.21
foreach: 0.0025961399078369, array_walk: 0.0027370452880859, array_map: 0.004054069519043\n
Output for 5.4.20
foreach: 0.0020108222961426, array_walk: 0.0019850730895996, array_map: 0.0030310153961182\n
Output for 5.4.19
foreach: 0.0020930767059326, array_walk: 0.0020909309387207, array_map: 0.0031869411468506\n
Output for 5.4.18
foreach: 0.0015311241149902, array_walk: 0.001572847366333, array_map: 0.002249002456665\n
Output for 5.4.17
foreach: 0.0014901161193848, array_walk: 0.0014059543609619, array_map: 0.0021159648895264\n
Output for 5.4.16
foreach: 0.0024919509887695, array_walk: 0.0024840831756592, array_map: 0.0035889148712158\n
Output for 5.4.15
foreach: 0.0025768280029297, array_walk: 0.0024640560150146, array_map: 0.0037951469421387\n
Output for 5.4.14
foreach: 0.0028579235076904, array_walk: 0.0027749538421631, array_map: 0.0040359497070312\n
Output for 5.4.13
foreach: 0.0026078224182129, array_walk: 0.0026991367340088, array_map: 0.0039389133453369\n
Output for 5.4.12
foreach: 0.0026710033416748, array_walk: 0.0026280879974365, array_map: 0.0038671493530273\n
Output for 5.4.11
foreach: 0.0025300979614258, array_walk: 0.0024991035461426, array_map: 0.0038309097290039\n
Output for 5.4.10
foreach: 0.0026290416717529, array_walk: 0.0026021003723145, array_map: 0.003978967666626\n
Output for 5.4.9
foreach: 0.0026600360870361, array_walk: 0.0030519962310791, array_map: 0.0045111179351807\n
Output for 5.4.8
foreach: 0.002500057220459, array_walk: 0.0022530555725098, array_map: 0.0033559799194336\n
Output for 5.4.7
foreach: 0.0025339126586914, array_walk: 0.0024771690368652, array_map: 0.0038280487060547\n
Output for 5.4.6
foreach: 0.0023319721221924, array_walk: 0.0023810863494873, array_map: 0.0034329891204834\n
Output for 5.4.5
foreach: 0.0024697780609131, array_walk: 0.002295970916748, array_map: 0.0036771297454834\n
Output for 5.4.4
foreach: 0.0019040107727051, array_walk: 0.0019581317901611, array_map: 0.0028409957885742\n
Output for 5.4.3
foreach: 0.0014491081237793, array_walk: 0.0014839172363281, array_map: 0.0020890235900879\n
Output for 5.4.2
foreach: 0.0019769668579102, array_walk: 0.0019569396972656, array_map: 0.0029399394989014\n
Output for 5.4.1
foreach: 0.0027060508728027, array_walk: 0.0029079914093018, array_map: 0.0041940212249756\n
Output for 5.4.0
foreach: 0.0024838447570801, array_walk: 0.0026788711547852, array_map: 0.0036749839782715\n
Output for 5.3.29
foreach: 0.0029079914093018, array_walk: 0.0029520988464355, array_map: 0.0042088031768799\n
Output for 5.3.28
foreach: 0.0029680728912354, array_walk: 0.0027270317077637, array_map: 0.0040881633758545\n
Output for 5.3.27
foreach: 0.0026230812072754, array_walk: 0.0025391578674316, array_map: 0.0037610530853271\n
Output for 5.3.26
foreach: 0.0028820037841797, array_walk: 0.002730131149292, array_map: 0.0039470195770264\n
Output for 5.3.25
foreach: 0.002938985824585, array_walk: 0.0027370452880859, array_map: 0.0041670799255371\n
Output for 5.3.24
foreach: 0.0031800270080566, array_walk: 0.0027449131011963, array_map: 0.004101037979126\n
Output for 5.3.23
foreach: 0.002957820892334, array_walk: 0.0027251243591309, array_map: 0.0040860176086426\n
Output for 5.3.22
foreach: 0.00301194190979, array_walk: 0.0028889179229736, array_map: 0.0042998790740967\n
Output for 5.3.21
foreach: 0.0028321743011475, array_walk: 0.0027179718017578, array_map: 0.0039801597595215\n
Output for 5.3.20
foreach: 0.0030419826507568, array_walk: 0.002877950668335, array_map: 0.0041990280151367\n
Output for 5.3.19
foreach: 0.0029828548431396, array_walk: 0.0030949115753174, array_map: 0.0042588710784912\n
Output for 5.3.18
foreach: 0.003180980682373, array_walk: 0.0030269622802734, array_map: 0.0044448375701904\n
Output for 5.3.17
foreach: 0.0029799938201904, array_walk: 0.0026781558990479, array_map: 0.0040900707244873\n
Output for 5.3.16
foreach: 0.0025730133056641, array_walk: 0.0022709369659424, array_map: 0.0033619403839111\n
Output for 5.3.15
foreach: 0.0022890567779541, array_walk: 0.0021920204162598, array_map: 0.0032482147216797\n
Output for 5.3.14
foreach: 0.0022830963134766, array_walk: 0.0022079944610596, array_map: 0.0034310817718506\n
Output for 5.3.13
foreach: 0.0016090869903564, array_walk: 0.0015130043029785, array_map: 0.0022189617156982\n
Output for 5.3.12
foreach: 0.003046989440918, array_walk: 0.0028891563415527, array_map: 0.004263162612915\n
Output for 5.3.11
foreach: 0.0030460357666016, array_walk: 0.002892017364502, array_map: 0.0043008327484131\n
Output for 5.3.10
foreach: 0.0028829574584961, array_walk: 0.0028519630432129, array_map: 0.0042569637298584\n
Output for 5.3.9
foreach: 0.002392053604126, array_walk: 0.0023078918457031, array_map: 0.0034480094909668\n
Output for 5.3.8
foreach: 0.0029809474945068, array_walk: 0.0028259754180908, array_map: 0.0039849281311035\n
Output for 5.3.7
foreach: 0.0029139518737793, array_walk: 0.0029330253601074, array_map: 0.0042440891265869\n
Output for 5.3.6
foreach: 0.0027430057525635, array_walk: 0.0027110576629639, array_map: 0.0040090084075928\n
Output for 5.3.5
foreach: 0.0029928684234619, array_walk: 0.0027840137481689, array_map: 0.0046350955963135\n
Output for 5.3.4
foreach: 0.0025091171264648, array_walk: 0.0022687911987305, array_map: 0.005256175994873\n
Output for 5.3.3
foreach: 0.0025460720062256, array_walk: 0.002565860748291, array_map: 0.0038449764251709\n
Output for 5.3.2
foreach: 0.0035378932952881, array_walk: 0.0029411315917969, array_map: 0.004349946975708\n
Output for 5.3.1
foreach: 0.0030138492584229, array_walk: 0.0028891563415527, array_map: 0.0042290687561035\n
Output for 5.3.0
foreach: 0.002960205078125, array_walk: 0.0025708675384521, array_map: 0.0038421154022217\n
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/LKiJ7 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/LKiJ7 on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/LKiJ7 on line 5
Process exited with code 255.