3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Undefined constant "sort_function" in /in/pIoMC:24 Stack trace: #0 {main} thrown in /in/pIoMC on line 24
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant sort_function - assumed 'sort_function' (this will throw an Error in a future version of PHP) 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.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
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.3.11, 4.4.0 - 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.

preferences:
307.87 ms | 401 KiB | 460 Q