3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = array( 'asd', 'ASD', 'sdf', 'SDF', 'Third', ); $b = array( '2 a', '1 b', '20 c', '10 d', '3 e', ); array_multisort($b, SORT_NATURAL, $a); var_dump($a, $b); array_multisort($b, SORT_LOCALE_STRING, $a); var_dump($a, $b); array_multisort($b, SORT_NATURAL, $a); var_dump($a, SORT_FLAG_CASE, $b);
Output for 5.4.0 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(5) { [0]=> string(3) "ASD" [1]=> string(3) "asd" [2]=> string(5) "Third" [3]=> string(3) "SDF" [4]=> string(3) "sdf" } array(5) { [0]=> string(3) "1 b" [1]=> string(3) "2 a" [2]=> string(3) "3 e" [3]=> string(4) "10 d" [4]=> string(4) "20 c" } array(5) { [0]=> string(3) "ASD" [1]=> string(3) "SDF" [2]=> string(3) "asd" [3]=> string(3) "sdf" [4]=> string(5) "Third" } array(5) { [0]=> string(3) "1 b" [1]=> string(4) "10 d" [2]=> string(3) "2 a" [3]=> string(4) "20 c" [4]=> string(3) "3 e" } array(5) { [0]=> string(3) "ASD" [1]=> string(3) "asd" [2]=> string(5) "Third" [3]=> string(3) "SDF" [4]=> string(3) "sdf" } int(8) array(5) { [0]=> string(3) "1 b" [1]=> string(3) "2 a" [2]=> string(3) "3 e" [3]=> string(4) "10 d" [4]=> string(4) "20 c" }
Output for 5.3.0 - 5.3.29
Notice: Use of undefined constant SORT_NATURAL - assumed 'SORT_NATURAL' in /in/sl6WP on line 18 Warning: array_multisort(): Argument #2 is expected to be an array or a sort flag in /in/sl6WP on line 18 array(5) { [0]=> string(3) "asd" [1]=> string(3) "ASD" [2]=> string(3) "sdf" [3]=> string(3) "SDF" [4]=> string(5) "Third" } array(5) { [0]=> string(3) "2 a" [1]=> string(3) "1 b" [2]=> string(4) "20 c" [3]=> string(4) "10 d" [4]=> string(3) "3 e" } array(5) { [0]=> string(3) "ASD" [1]=> string(3) "SDF" [2]=> string(3) "asd" [3]=> string(3) "sdf" [4]=> string(5) "Third" } array(5) { [0]=> string(3) "1 b" [1]=> string(4) "10 d" [2]=> string(3) "2 a" [3]=> string(4) "20 c" [4]=> string(3) "3 e" } Notice: Use of undefined constant SORT_NATURAL - assumed 'SORT_NATURAL' in /in/sl6WP on line 26 Warning: array_multisort(): Argument #2 is expected to be an array or a sort flag in /in/sl6WP on line 26 Notice: Use of undefined constant SORT_FLAG_CASE - assumed 'SORT_FLAG_CASE' in /in/sl6WP on line 28 array(5) { [0]=> string(3) "ASD" [1]=> string(3) "SDF" [2]=> string(3) "asd" [3]=> string(3) "sdf" [4]=> string(5) "Third" } string(14) "SORT_FLAG_CASE" array(5) { [0]=> string(3) "1 b" [1]=> string(4) "10 d" [2]=> string(3) "2 a" [3]=> string(4) "20 c" [4]=> string(3) "3 e" }
Output for 4.4.0 - 4.4.9, 5.0.2 - 5.2.17
Notice: Use of undefined constant SORT_NATURAL - assumed 'SORT_NATURAL' in /in/sl6WP on line 18 Warning: array_multisort(): Argument #2 is expected to be an array or a sort flag in /in/sl6WP on line 18 array(5) { [0]=> string(3) "asd" [1]=> string(3) "ASD" [2]=> string(3) "sdf" [3]=> string(3) "SDF" [4]=> string(5) "Third" } array(5) { [0]=> string(3) "2 a" [1]=> string(3) "1 b" [2]=> string(4) "20 c" [3]=> string(4) "10 d" [4]=> string(3) "3 e" } Warning: array_multisort(): Argument #2 is an unknown sort flag in /in/sl6WP on line 22 array(5) { [0]=> string(3) "asd" [1]=> string(3) "ASD" [2]=> string(3) "sdf" [3]=> string(3) "SDF" [4]=> string(5) "Third" } array(5) { [0]=> string(3) "2 a" [1]=> string(3) "1 b" [2]=> string(4) "20 c" [3]=> string(4) "10 d" [4]=> string(3) "3 e" } Notice: Use of undefined constant SORT_NATURAL - assumed 'SORT_NATURAL' in /in/sl6WP on line 26 Warning: array_multisort(): Argument #2 is expected to be an array or a sort flag in /in/sl6WP on line 26 Notice: Use of undefined constant SORT_FLAG_CASE - assumed 'SORT_FLAG_CASE' in /in/sl6WP on line 28 array(5) { [0]=> string(3) "asd" [1]=> string(3) "ASD" [2]=> string(3) "sdf" [3]=> string(3) "SDF" [4]=> string(5) "Third" } string(14) "SORT_FLAG_CASE" array(5) { [0]=> string(3) "2 a" [1]=> string(3) "1 b" [2]=> string(4) "20 c" [3]=> string(4) "10 d" [4]=> string(3) "3 e" }
Output for 4.3.2 - 4.3.11, 5.0.0 - 5.0.1
Notice: Use of undefined constant SORT_NATURAL - assumed 'SORT_NATURAL' in /in/sl6WP on line 18 Warning: array_multisort(): Argument #2 is expected to be an array or a sort flag in /in/sl6WP on line 18 array(5) { [0]=> string(3) "asd" [1]=> string(3) "ASD" [2]=> string(3) "sdf" [3]=> string(3) "SDF" [4]=> string(5) "Third" } array(5) { [0]=> string(3) "2 a" [1]=> string(3) "1 b" [2]=> string(4) "20 c" [3]=> string(4) "10 d" [4]=> string(3) "3 e" } Notice: Use of undefined constant SORT_LOCALE_STRING - assumed 'SORT_LOCALE_STRING' in /in/sl6WP on line 22 Warning: array_multisort(): Argument #2 is expected to be an array or a sort flag in /in/sl6WP on line 22 array(5) { [0]=> string(3) "asd" [1]=> string(3) "ASD" [2]=> string(3) "sdf" [3]=> string(3) "SDF" [4]=> string(5) "Third" } array(5) { [0]=> string(3) "2 a" [1]=> string(3) "1 b" [2]=> string(4) "20 c" [3]=> string(4) "10 d" [4]=> string(3) "3 e" } Notice: Use of undefined constant SORT_NATURAL - assumed 'SORT_NATURAL' in /in/sl6WP on line 26 Warning: array_multisort(): Argument #2 is expected to be an array or a sort flag in /in/sl6WP on line 26 Notice: Use of undefined constant SORT_FLAG_CASE - assumed 'SORT_FLAG_CASE' in /in/sl6WP on line 28 array(5) { [0]=> string(3) "asd" [1]=> string(3) "ASD" [2]=> string(3) "sdf" [3]=> string(3) "SDF" [4]=> string(5) "Third" } string(14) "SORT_FLAG_CASE" array(5) { [0]=> string(3) "2 a" [1]=> string(3) "1 b" [2]=> string(4) "20 c" [3]=> string(4) "10 d" [4]=> string(3) "3 e" }
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant SORT_NATURAL - assumed 'SORT_NATURAL' in /in/sl6WP on line 18 Warning: array_multisort() [http://www.php.net/function.array-multisort]: Argument #2 is expected to be an array or a sort flag in /in/sl6WP on line 18 array(5) { [0]=> string(3) "asd" [1]=> string(3) "ASD" [2]=> string(3) "sdf" [3]=> string(3) "SDF" [4]=> string(5) "Third" } array(5) { [0]=> string(3) "2 a" [1]=> string(3) "1 b" [2]=> string(4) "20 c" [3]=> string(4) "10 d" [4]=> string(3) "3 e" } Notice: Use of undefined constant SORT_LOCALE_STRING - assumed 'SORT_LOCALE_STRING' in /in/sl6WP on line 22 Warning: array_multisort() [http://www.php.net/function.array-multisort]: Argument #2 is expected to be an array or a sort flag in /in/sl6WP on line 22 array(5) { [0]=> string(3) "asd" [1]=> string(3) "ASD" [2]=> string(3) "sdf" [3]=> string(3) "SDF" [4]=> string(5) "Third" } array(5) { [0]=> string(3) "2 a" [1]=> string(3) "1 b" [2]=> string(4) "20 c" [3]=> string(4) "10 d" [4]=> string(3) "3 e" } Notice: Use of undefined constant SORT_NATURAL - assumed 'SORT_NATURAL' in /in/sl6WP on line 26 Warning: array_multisort() [http://www.php.net/function.array-multisort]: Argument #2 is expected to be an array or a sort flag in /in/sl6WP on line 26 Notice: Use of undefined constant SORT_FLAG_CASE - assumed 'SORT_FLAG_CASE' in /in/sl6WP on line 28 array(5) { [0]=> string(3) "asd" [1]=> string(3) "ASD" [2]=> string(3) "sdf" [3]=> string(3) "SDF" [4]=> string(5) "Third" } string(14) "SORT_FLAG_CASE" array(5) { [0]=> string(3) "2 a" [1]=> string(3) "1 b" [2]=> string(4) "20 c" [3]=> string(4) "10 d" [4]=> string(3) "3 e" }