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) .'<br /><br />'; $start_time2 = microtime(TRUE); $outputData = array_map(function($user){ return array( 'name' => $user['name'], 'email' => $user['email'], 'banned' => $user['banned'], ); }, $data) $end_time2 = microtime(TRUE); echo 'Array_map: '.($end_time2 - $start_time2) .'<br /><br />';
Output for 5.4.0 - 5.4.22
Parse error: syntax error, unexpected '$end_time2' (T_VARIABLE) in /in/BATCA on line 45
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_VARIABLE in /in/BATCA on line 45
Process exited with code 255.