3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $scores = array( "Mike" => array(04, 03, 00, 07, 04, 07, 00, 01, 00, 07, 04), "Kyle" => array(07, 01, 00, 03, 04, 01, 00, 07, 03, 04, 04), "Johnny" => array(07, 07, 00, 03, 00, 04, 00, 01, 01, 04, 03), "Will" => array(03, 04, 00, 03, 04, 07, 00, 01, 00, 07, 04), "Vasques" => array(03, 01, 00, 03, 04, 07, 00, 01, 00, 07, 07) ); /* function cmp($a, $b) { return array_sum($b) - array_sum($a); } usort($scores, "cmp"); */ function sort_function(array $a, array $b) { $arr1_val = array_sum($a); $arr2_val = array_sum($b); return $arr2_val - $arr1_val; } usort($scores,sort_function); print_r($scores);
Output for 5.1.0 - 7.1.0
Notice: Use of undefined constant sort_function - assumed 'sort_function' in /in/pIoMC on line 24 Array ( [0] => Array ( [0] => 4 [1] => 3 [2] => 0 [3] => 7 [4] => 4 [5] => 7 [6] => 0 [7] => 1 [8] => 0 [9] => 7 [10] => 4 ) [1] => Array ( [0] => 7 [1] => 1 [2] => 0 [3] => 3 [4] => 4 [5] => 1 [6] => 0 [7] => 7 [8] => 3 [9] => 4 [10] => 4 ) [2] => Array ( [0] => 3 [1] => 4 [2] => 0 [3] => 3 [4] => 4 [5] => 7 [6] => 0 [7] => 1 [8] => 0 [9] => 7 [10] => 4 ) [3] => Array ( [0] => 3 [1] => 1 [2] => 0 [3] => 3 [4] => 4 [5] => 7 [6] => 0 [7] => 1 [8] => 0 [9] => 7 [10] => 7 ) [4] => Array ( [0] => 7 [1] => 7 [2] => 0 [3] => 3 [4] => 0 [5] => 4 [6] => 0 [7] => 1 [8] => 1 [9] => 4 [10] => 3 ) )
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/pIoMC on line 18
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /in/pIoMC on line 18
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_ARRAY, expecting ')' in /in/pIoMC on line 18
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/pIoMC on line 18
Process exited with code 255.