3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $order = array('ACO', 'ZCO', 'Other'); function compare($a, $b) { $ai = array_search($a, $order); $bi = array_search($b, $order); return $a<$b ? -1 : $a>$b; } $a = array('ZCO'=>1, 'Other'=>1, 'ACO'=>1); uksort($a, compare); print_r($a);
Output for 5.3.0 - 7.1.0
Notice: Use of undefined constant compare - assumed 'compare' in /in/e2JBf on line 12 Notice: Undefined variable: order in /in/e2JBf on line 7 Warning: array_search() expects parameter 2 to be array, null given in /in/e2JBf on line 7 Notice: Undefined variable: order in /in/e2JBf on line 8 Warning: array_search() expects parameter 2 to be array, null given in /in/e2JBf on line 8 Notice: Undefined variable: order in /in/e2JBf on line 7 Warning: array_search() expects parameter 2 to be array, null given in /in/e2JBf on line 7 Notice: Undefined variable: order in /in/e2JBf on line 8 Warning: array_search() expects parameter 2 to be array, null given in /in/e2JBf on line 8 Array ( [ACO] => 1 [Other] => 1 [ZCO] => 1 )
Output for 5.0.4 - 5.2.17
Notice: Use of undefined constant compare - assumed 'compare' in /in/e2JBf on line 12 Notice: Undefined variable: order in /in/e2JBf on line 7 Warning: array_search(): Wrong datatype for second argument in /in/e2JBf on line 7 Notice: Undefined variable: order in /in/e2JBf on line 8 Warning: array_search(): Wrong datatype for second argument in /in/e2JBf on line 8 Notice: Undefined variable: order in /in/e2JBf on line 7 Warning: array_search(): Wrong datatype for second argument in /in/e2JBf on line 7 Notice: Undefined variable: order in /in/e2JBf on line 8 Warning: array_search(): Wrong datatype for second argument in /in/e2JBf on line 8 Array ( [ACO] => 1 [Other] => 1 [ZCO] => 1 )
Output for 4.3.2 - 5.0.3
Notice: Use of undefined constant compare - assumed 'compare' in /in/e2JBf on line 12 Notice: Undefined variable: order in /in/e2JBf on line 7 Warning: array_search(): Wrong datatype for second argument in /in/e2JBf on line 7 Notice: Undefined variable: order in /in/e2JBf on line 8 Warning: array_search(): Wrong datatype for second argument in /in/e2JBf on line 8 Notice: Undefined variable: order in /in/e2JBf on line 7 Warning: array_search(): Wrong datatype for second argument in /in/e2JBf on line 7 Notice: Undefined variable: order in /in/e2JBf on line 8 Warning: array_search(): Wrong datatype for second argument in /in/e2JBf on line 8 Array ( [ACO] => 1 [Other] => 1 [ZCO] => 1 )
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant compare - assumed 'compare' in /in/e2JBf on line 12 Notice: Undefined variable: order in /in/e2JBf on line 7 Warning: array_search() [http://www.php.net/function.array-search]: Wrong datatype for second argument in /in/e2JBf on line 7 Notice: Undefined variable: order in /in/e2JBf on line 8 Warning: array_search() [http://www.php.net/function.array-search]: Wrong datatype for second argument in /in/e2JBf on line 8 Notice: Undefined variable: order in /in/e2JBf on line 7 Warning: array_search() [http://www.php.net/function.array-search]: Wrong datatype for second argument in /in/e2JBf on line 7 Notice: Undefined variable: order in /in/e2JBf on line 8 Warning: array_search() [http://www.php.net/function.array-search]: Wrong datatype for second argument in /in/e2JBf on line 8 Array ( [ACO] => 1 [Other] => 1 [ZCO] => 1 )