3v4l.org

run code in 300+ PHP versions simultaneously
<?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);
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: {closure}(): Argument #1 ($x) must be passed by reference, value given in /in/JMDp9 on line 21 Warning: {closure}(): Argument #2 ($y) must be passed by reference, value given in /in/JMDp9 on line 21 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 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: {closure}(): Argument #1 ($x) must be passed by reference, value given in /in/JMDp9 on line 21 Warning: {closure}(): Argument #2 ($y) must be passed by reference, value given in /in/JMDp9 on line 21 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 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Warning: {closure}(): Argument #1 ($x) must be passed by reference, value given in /in/JMDp9 on line 29 Warning: {closure}(): Argument #2 ($y) must be passed by reference, value given in /in/JMDp9 on line 29 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 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
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.24 - 5.5.35, 5.6.8 - 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" } }

preferences:
187.14 ms | 403 KiB | 198 Q