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']); return strcasecmp($x['name'], $y['name']); }); var_dump($array);
based on 0FPFQ
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.5.0 - 5.6.28
array(2) { [0]=> array(2) { ["name"]=> string(3) "Bar" ["children"]=> array(3) { [0]=> string(1) "X" [1]=> string(1) "Y" [2]=> string(1) "Z" } } [1]=> array(2) { ["name"]=> string(3) "Foo" ["children"]=> array(2) { [0]=> string(1) "A" [1]=> string(1) "B" } } }