3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = array( array( 'name' => 'Foo', 'children' => array( 'B', 'A', ), ), array( 'name' => 'Bar', 'children' => array( 'Z', 'X', 'Y', ), ), ); usort($array, function (&$x, &$y) { sort($x['children']); sort($y['children']); $x[] = 'Test'; $y[] = 'Test2'; return strcasecmp($x['name'], $y['name']); }); var_dump($array);
based on bT5ru
Output for 7.0.0 - 7.2.0
array(2) { [0]=> array(2) { ["name"]=> string(3) "Bar" ["children"]=> array(3) { [0]=> string(1) "Z" [1]=> string(1) "X" [2]=> string(1) "Y" } } [1]=> array(2) { ["name"]=> string(3) "Foo" ["children"]=> array(2) { [0]=> string(1) "B" [1]=> string(1) "A" } } }
Output for 5.3.21 - 5.6.28
array(2) { [0]=> array(3) { ["name"]=> string(3) "Bar" ["children"]=> array(3) { [0]=> string(1) "X" [1]=> string(1) "Y" [2]=> string(1) "Z" } [0]=> string(4) "Test" } [1]=> array(3) { ["name"]=> string(3) "Foo" ["children"]=> array(2) { [0]=> string(1) "A" [1]=> string(1) "B" } [0]=> string(5) "Test2" } }