3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $data = array( array('name' => 'User 1', 'email' => 'user.1@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 2', 'email' => 'user.2@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 3', 'email' => 'user.3@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 4', 'email' => 'user.4@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 5', 'email' => 'user.5@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 6', 'email' => 'user.6@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 7', 'email' => 'user.7@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 8', 'email' => 'user.8@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 9', 'email' => 'user.9@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 10', 'email' => 'user.10@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 11', 'email' => 'user.11@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), ); $start_time1 = microtime(TRUE); $outputData = array(); foreach($data as $id => $user){ $outputData[] = array( 'name' => $user['name'], 'email' => $user['email'], 'banned' => $user['banned'], ); } //var_dump($outputData); $end_time1 = microtime(TRUE); echo 'Foreach: '.($end_time1 - $start_time1) ."\n\n"; $start_time2 = microtime(TRUE); $outputData = array_map(function($user){ return array( 'name' => $user['name'], 'email' => $user['email'], 'banned' => $user['banned'], ); }, $data); //var_dump($outputData); $end_time2 = microtime(TRUE); echo 'Array_map: '.($end_time2 - $start_time2) ."\n\n";
Output for 7.1.0
Foreach: 4.0531158447266E-6 Array_map: 6.9141387939453E-6
Output for 7.0.3, 7.0.14
Foreach: 6.9141387939453E-6 Array_map: 1.0013580322266E-5
Output for 7.0.7
Foreach: 5.0067901611328E-6 Array_map: 7.8678131103516E-6
Output for 7.0.0, 7.0.6
Foreach: 5.9604644775391E-6 Array_map: 8.1062316894531E-6
Output for 7.0.5
Foreach: 5.0067901611328E-6 Array_map: 7.1525573730469E-6
Output for 7.0.4
Foreach: 5.9604644775391E-6 Array_map: 9.0599060058594E-6
Output for 7.0.2
Foreach: 7.1525573730469E-6 Array_map: 1.0013580322266E-5
Output for 7.0.1
Foreach: 6.9141387939453E-6 Array_map: 1.4066696166992E-5
Output for hhvm-3.12.0
Foreach: 1.5020370483398E-5 Array_map: 1.9073486328125E-5
Output for hhvm-3.10.0
Foreach: 1.9073486328125E-5 Array_map: 2.9087066650391E-5
Output for 5.6.28
Foreach: 1.4066696166992E-5 Array_map: 2.2172927856445E-5
Output for 5.6.22
Foreach: 1.2874603271484E-5 Array_map: 1.8835067749023E-5
Output for 5.6.21
Foreach: 1.1920928955078E-5 Array_map: 1.5974044799805E-5
Output for 5.4.16, 5.4.25, 5.5.7, 5.6.20
Foreach: 1.0013580322266E-5 Array_map: 1.5020370483398E-5
Output for 5.6.19
Foreach: 1.0013580322266E-5 Array_map: 1.5974044799805E-5
Output for 5.6.18
Foreach: 1.2874603271484E-5 Array_map: 2.598762512207E-5
Output for 5.4.18, 5.4.38, 5.6.17
Foreach: 1.5974044799805E-5 Array_map: 2.3126602172852E-5
Output for 5.6.16
Foreach: 1.5020370483398E-5 Array_map: 3.3140182495117E-5
Output for 5.4.1, 5.4.26, 5.5.35, 5.6.15
Foreach: 1.5020370483398E-5 Array_map: 2.4080276489258E-5
Output for 5.4.6, 5.6.14
Foreach: 1.1205673217773E-5 Array_map: 1.5974044799805E-5
Output for 5.6.13
Foreach: 1.215934753418E-5 Array_map: 2.7894973754883E-5
Output for 5.5.11, 5.5.26, 5.6.8, 5.6.12
Foreach: 1.5020370483398E-5 Array_map: 2.1934509277344E-5
Output for 5.5.27, 5.6.3, 5.6.11
Foreach: 1.5020370483398E-5 Array_map: 2.0980834960938E-5
Output for 5.6.10
Foreach: 1.1920928955078E-5 Array_map: 2.7179718017578E-5
Output for 5.6.9
Foreach: 1.3113021850586E-5 Array_map: 2.0027160644531E-5
Output for 5.5.1, 5.6.7
Foreach: 1.1920928955078E-5 Array_map: 1.9073486328125E-5
Output for 5.6.6
Foreach: 1.4066696166992E-5 Array_map: 1.8835067749023E-5
Output for 5.4.4, 5.4.20, 5.4.23, 5.4.31, 5.5.15, 5.6.5
Foreach: 1.4066696166992E-5 Array_map: 2.0980834960938E-5
Output for 5.5.32, 5.6.4
Foreach: 1.1920928955078E-5 Array_map: 1.8119812011719E-5
Output for 5.6.2
Foreach: 1.6212463378906E-5 Array_map: 2.5033950805664E-5
Output for 5.6.1
Foreach: 1.4781951904297E-5 Array_map: 2.3841857910156E-5
Output for 5.6.0
Foreach: 1.5020370483398E-5 Array_map: 2.2172927856445E-5
Output for 5.4.39, 5.5.36
Foreach: 1.5974044799805E-5 Array_map: 2.288818359375E-5
Output for 5.4.36, 5.5.19, 5.5.23, 5.5.34
Foreach: 1.1920928955078E-5 Array_map: 1.7881393432617E-5
Output for 5.5.33
Foreach: 1.2874603271484E-5 Array_map: 1.5974044799805E-5
Output for 5.5.31
Foreach: 1.4066696166992E-5 Array_map: 1.5974044799805E-5
Output for 5.4.19, 5.4.42, 5.5.8, 5.5.30
Foreach: 1.0967254638672E-5 Array_map: 1.5974044799805E-5
Output for 5.5.29
Foreach: 2.288818359375E-5 Array_map: 1.9073486328125E-5
Output for 5.5.28
Foreach: 1.3828277587891E-5 Array_map: 2.0027160644531E-5
Output for 5.5.25
Foreach: 1.1920928955078E-5 Array_map: 2.4795532226562E-5
Output for 5.5.24
Foreach: 1.9073486328125E-5 Array_map: 2.4080276489258E-5
Output for 5.4.7, 5.5.22
Foreach: 1.4066696166992E-5 Array_map: 2.9802322387695E-5
Output for 5.5.21
Foreach: 1.0967254638672E-5 Array_map: 2.2172927856445E-5
Output for 5.5.20
Foreach: 1.5974044799805E-5 Array_map: 3.0994415283203E-5
Output for 5.5.18
Foreach: 1.2874603271484E-5 Array_map: 1.7881393432617E-5
Output for 5.4.45, 5.5.16
Foreach: 1.3113021850586E-5 Array_map: 1.9073486328125E-5
Output for 5.4.32, 5.5.14
Foreach: 1.4066696166992E-5 Array_map: 2.1934509277344E-5
Output for 5.5.13
Foreach: 1.7881393432617E-5 Array_map: 2.0980834960938E-5
Output for 5.5.12
Foreach: 1.3113021850586E-5 Array_map: 3.0040740966797E-5
Output for 5.5.10
Foreach: 1.215934753418E-5 Array_map: 1.8835067749023E-5
Output for 5.4.22, 5.5.9
Foreach: 1.0967254638672E-5 Array_map: 2.1934509277344E-5
Output for 5.3.7, 5.5.6
Foreach: 1.4066696166992E-5 Array_map: 1.9073486328125E-5
Output for 5.5.5
Foreach: 1.6927719116211E-5 Array_map: 2.5033950805664E-5
Output for 5.5.4
Foreach: 1.4066696166992E-5 Array_map: 3.0994415283203E-5
Output for 5.5.3
Foreach: 1.5020370483398E-5 Array_map: 3.2186508178711E-5
Output for 5.5.2
Foreach: 1.4066696166992E-5 Array_map: 3.0040740966797E-5
Output for 5.5.0
Foreach: 1.0967254638672E-5 Array_map: 1.6927719116211E-5
Output for 5.4.44
Foreach: 1.0013580322266E-5 Array_map: 1.4066696166992E-5
Output for 5.4.43
Foreach: 1.6212463378906E-5 Array_map: 2.1934509277344E-5
Output for 5.4.41
Foreach: 2.1219253540039E-5 Array_map: 2.4080276489258E-5
Output for 5.4.40
Foreach: 1.4781951904297E-5 Array_map: 2.0980834960938E-5
Output for 5.4.37
Foreach: 1.2874603271484E-5 Array_map: 1.9073486328125E-5
Output for 5.3.29, 5.4.21, 5.4.35
Foreach: 1.5974044799805E-5 Array_map: 2.1934509277344E-5
Output for 5.4.34
Foreach: 1.5974044799805E-5 Array_map: 2.9087066650391E-5
Output for 5.4.30
Foreach: 1.2874603271484E-5 Array_map: 2.7894973754883E-5
Output for 5.4.29
Foreach: 1.4781951904297E-5 Array_map: 2.2172927856445E-5
Output for 5.4.13, 5.4.28
Foreach: 1.5020370483398E-5 Array_map: 3.1948089599609E-5
Output for 5.4.27
Foreach: 1.7166137695312E-5 Array_map: 2.4080276489258E-5
Output for 5.4.0, 5.4.24
Foreach: 1.0967254638672E-5 Array_map: 1.7166137695312E-5
Output for 5.4.17
Foreach: 1.0013580322266E-5 Array_map: 2.1934509277344E-5
Output for 5.4.15
Foreach: 1.5974044799805E-5 Array_map: 3.2901763916016E-5
Output for 5.4.14
Foreach: 1.3113021850586E-5 Array_map: 3.0994415283203E-5
Output for 5.4.12
Foreach: 1.1205673217773E-5 Array_map: 2.3126602172852E-5
Output for 5.4.11
Foreach: 1.5974044799805E-5 Array_map: 3.1948089599609E-5
Output for 5.3.16, 5.4.10
Foreach: 1.0967254638672E-5 Array_map: 1.3828277587891E-5
Output for 5.4.9
Foreach: 1.1920928955078E-5 Array_map: 2.0027160644531E-5
Output for 5.4.8
Foreach: 1.0013580322266E-5 Array_map: 2.288818359375E-5
Output for 5.3.9 - 5.3.10, 5.4.5
Foreach: 1.0967254638672E-5 Array_map: 1.5020370483398E-5
Output for 5.4.3
Foreach: 1.215934753418E-5 Array_map: 2.4795532226562E-5
Output for 5.4.2
Foreach: 1.5974044799805E-5 Array_map: 2.4080276489258E-5
Output for 5.3.28
Foreach: 2.0980834960938E-5 Array_map: 2.3841857910156E-5
Output for 5.3.27
Foreach: 1.215934753418E-5 Array_map: 1.5974044799805E-5
Output for 5.3.26
Foreach: 1.7166137695312E-5 Array_map: 2.288818359375E-5
Output for 5.3.25
Foreach: 1.5974044799805E-5 Array_map: 2.2172927856445E-5
Output for 5.3.24
Foreach: 2.7894973754883E-5 Array_map: 3.6001205444336E-5
Output for 5.3.23
Foreach: 1.1920928955078E-5 Array_map: 1.5020370483398E-5
Output for 5.3.22
Foreach: 1.6927719116211E-5 Array_map: 2.288818359375E-5
Output for 5.3.21
Foreach: 1.1920928955078E-5 Array_map: 2.3841857910156E-5
Output for 5.3.20
Foreach: 1.9073486328125E-5 Array_map: 2.288818359375E-5
Output for 5.3.19
Foreach: 1.2874603271484E-5 Array_map: 1.7166137695312E-5
Output for 5.3.18
Foreach: 1.7881393432617E-5 Array_map: 3.6001205444336E-5
Output for 5.3.17
Foreach: 1.5020370483398E-5 Array_map: 2.7894973754883E-5
Output for 5.3.15
Foreach: 1.2874603271484E-5 Array_map: 2.5033950805664E-5
Output for 5.3.6, 5.3.13 - 5.3.14
Foreach: 1.5974044799805E-5 Array_map: 2.0980834960938E-5
Output for 5.3.12
Foreach: 1.6927719116211E-5 Array_map: 3.2901763916016E-5
Output for 5.3.11
Foreach: 1.6927719116211E-5 Array_map: 2.2172927856445E-5
Output for 5.3.5, 5.3.8
Foreach: 1.5020370483398E-5 Array_map: 2.0027160644531E-5
Output for 5.3.3 - 5.3.4
Foreach: 1.7166137695312E-5 Array_map: 2.1934509277344E-5
Output for 5.3.2
Foreach: 1.7881393432617E-5 Array_map: 2.598762512207E-5
Output for 5.3.1
Foreach: 1.7166137695312E-5 Array_map: 3.0994415283203E-5
Output for 5.3.0
Foreach: 1.6927719116211E-5 Array_map: 2.1219253540039E-5
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/2nFlT on line 37
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, expecting ')' in /in/2nFlT on line 37
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/2nFlT on line 37
Process exited with code 255.