3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $names = array('Alpha', 'bravo', 'Charly', 'delta', 'Echo'); $sorts = array( 'regular' => SORT_REGULAR, 'numeric' => SORT_NUMERIC, 'string' => SORT_STRING, 'natural' => SORT_NATURAL, 'case_string ' => SORT_FLAG_CASE | SORT_FLAG_CASE, 'case_natural' => SORT_NATURAL | SORT_FLAG_CASE, ); print_r($names); foreach ($sorts as $name => $flag) { sort($names, $flag); echo $name ."\r\n"; print_r($names); }
based on ueAdb
Output for 7.0.0 - 7.2.0
Array ( [0] => Alpha [1] => bravo [2] => Charly [3] => delta [4] => Echo ) regular Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta ) numeric Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta ) string Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta ) natural Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta ) case_string Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta ) case_natural Array ( [0] => Alpha [1] => bravo [2] => Charly [3] => delta [4] => Echo )
Output for 5.4.12 - 5.6.21
Array ( [0] => Alpha [1] => bravo [2] => Charly [3] => delta [4] => Echo ) regular Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta ) numeric Array ( [0] => delta [1] => bravo [2] => Echo [3] => Charly [4] => Alpha ) string Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta ) natural Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta ) case_string Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta ) case_natural Array ( [0] => Alpha [1] => bravo [2] => Charly [3] => delta [4] => Echo )
Output for 5.3.22 - 5.3.29
Notice: Use of undefined constant SORT_NATURAL - assumed 'SORT_NATURAL' in /in/oXHsT on line 9 Notice: Use of undefined constant SORT_FLAG_CASE - assumed 'SORT_FLAG_CASE' in /in/oXHsT on line 10 Notice: Use of undefined constant SORT_FLAG_CASE - assumed 'SORT_FLAG_CASE' in /in/oXHsT on line 10 Notice: Use of undefined constant SORT_NATURAL - assumed 'SORT_NATURAL' in /in/oXHsT on line 11 Notice: Use of undefined constant SORT_FLAG_CASE - assumed 'SORT_FLAG_CASE' in /in/oXHsT on line 11 Array ( [0] => Alpha [1] => bravo [2] => Charly [3] => delta [4] => Echo ) regular Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta ) numeric Array ( [0] => delta [1] => bravo [2] => Echo [3] => Charly [4] => Alpha ) string Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta ) Warning: sort() expects parameter 2 to be long, string given in /in/oXHsT on line 17 natural Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta ) Warning: sort() expects parameter 2 to be long, string given in /in/oXHsT on line 17 case_string Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta ) Warning: sort() expects parameter 2 to be long, string given in /in/oXHsT on line 17 case_natural Array ( [0] => Alpha [1] => Charly [2] => Echo [3] => bravo [4] => delta )