3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = [ ['name' => 'third1', 'order' => 3], ['name' => 'first1', 'order' => 1], ['name' => 'third2', 'order' => 3], ['name' => 'second1', 'order' => 2], ['name' => 'fourth', 'order' => 4], ['name' => 'second2', 'order' => 2], ]; usort ($a, function ($a, $b) { if ($a['order'] == $b['order']) { return 0; } return ($a['order'] < $b['order']) ? -1 : 1; }); print_r ($a);
Output for 7.0.0 - 7.2.0
Array ( [0] => Array ( [name] => first1 [order] => 1 ) [1] => Array ( [name] => second1 [order] => 2 ) [2] => Array ( [name] => second2 [order] => 2 ) [3] => Array ( [name] => third1 [order] => 3 ) [4] => Array ( [name] => third2 [order] => 3 ) [5] => Array ( [name] => fourth [order] => 4 ) )
Output for 5.4.10 - 5.6.28
Array ( [0] => Array ( [name] => first1 [order] => 1 ) [1] => Array ( [name] => second2 [order] => 2 ) [2] => Array ( [name] => second1 [order] => 2 ) [3] => Array ( [name] => third2 [order] => 3 ) [4] => Array ( [name] => third1 [order] => 3 ) [5] => Array ( [name] => fourth [order] => 4 ) )
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/QhfUO on line 3
Process exited with code 255.