3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr =array( array(1,22,3,6,3), array(4,16,2,10,1), array(11,2,3,5,9), array(3,8,12,4,8) ); function vhall_sort($arr){ $a=$new=array(); foreach($arr as $k=>$v){ $num=array_sum($v); $a[$k]=$num/count($v); } arsort($a); foreach ($a as $k=>$v){ $new[$k] = $arr[$k]; } return $new; } echo '<pre>'; print_r($arr); print_r(vhall_sort($arr)); function vhall_sort_test($arr){ usort(&$arr, function($v1, $v2){ return (array_sum($v1)/count($v1) > array_sum($v2)/count($v2)) ? -1 : 1; }); } vhall_sort_test($arr); print_r($arr);
Output for 5.4.0 - 5.4.31
Fatal error: Call-time pass-by-reference has been removed in /in/Cp0dk on line 27
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Deprecated: Call-time pass-by-reference has been deprecated in /in/Cp0dk on line 27 <pre>Array ( [0] => Array ( [0] => 1 [1] => 22 [2] => 3 [3] => 6 [4] => 3 ) [1] => Array ( [0] => 4 [1] => 16 [2] => 2 [3] => 10 [4] => 1 ) [2] => Array ( [0] => 11 [1] => 2 [2] => 3 [3] => 5 [4] => 9 ) [3] => Array ( [0] => 3 [1] => 8 [2] => 12 [3] => 4 [4] => 8 ) ) Array ( [0] => Array ( [0] => 1 [1] => 22 [2] => 3 [3] => 6 [4] => 3 ) [3] => Array ( [0] => 3 [1] => 8 [2] => 12 [3] => 4 [4] => 8 ) [1] => Array ( [0] => 4 [1] => 16 [2] => 2 [3] => 10 [4] => 1 ) [2] => Array ( [0] => 11 [1] => 2 [2] => 3 [3] => 5 [4] => 9 ) ) Array ( [0] => Array ( [0] => 1 [1] => 22 [2] => 3 [3] => 6 [4] => 3 ) [1] => Array ( [0] => 4 [1] => 16 [2] => 2 [3] => 10 [4] => 1 ) [2] => Array ( [0] => 11 [1] => 2 [2] => 3 [3] => 5 [4] => 9 ) [3] => Array ( [0] => 3 [1] => 8 [2] => 12 [3] => 4 [4] => 8 ) )