3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php set_error_handler(function($errno, $errstr) { $bt = debug_backtrace(); var_dump($errstr); }); $input = array( 'first' => array(), 'second' => array('position' => 2), array('something' => 5), NULL => array('error' => 1), ); $displays = array(); foreach ($input as $key => $options) { $options += array( 'display_options' => array(), 'display_plugin' => NULL, 'id' => NULL, 'display_title' => '', 'position' => NULL, ); // Add the defaults for the display. $displays[$key] = $options; } uasort($displays, function ($display1, $display2) { if ($display1['position'] != $display2['position']) { return $display1['position'] < $display2['position'] ? -1 : 1; } return 0; }); print_r($displays);
Output for hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [first] => Array ( [display_options] => Array ( ) [display_plugin] => [id] => [display_title] => [position] => ) [0] => Array ( [something] => 5 [display_options] => Array ( ) [display_plugin] => [id] => [display_title] => [position] => ) [] => Array ( [error] => 1 [display_options] => Array ( ) [display_plugin] => [id] => [display_title] => [position] => ) [second] => Array ( [position] => 2 [display_options] => Array ( ) [display_plugin] => [id] => [display_title] => ) )
Output for 5.3.0 - 5.6.21
Array ( [0] => Array ( [something] => 5 [display_options] => Array ( ) [display_plugin] => [id] => [display_title] => [position] => ) [first] => Array ( [display_options] => Array ( ) [display_plugin] => [id] => [display_title] => [position] => ) [] => Array ( [error] => 1 [display_options] => Array ( ) [display_plugin] => [id] => [display_title] => [position] => ) [second] => Array ( [position] => 2 [display_options] => Array ( ) [display_plugin] => [id] => [display_title] => ) )
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/2JNRP on line 3
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/2JNRP on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/2JNRP on line 3
Process exited with code 255.