3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $scores = array( "Kyle" => array(07, 01, 00, 03, 04, 01, 00, 07, 03, 04, 04), "Mike" => array(04, 03, 00, 07, 04, 07, 00, 01, 00, 07, 04), "Will" => array(03, 04, 00, 03, 04, 07, 00, 01, 00, 07, 04), "Johnny" => array(07, 07, 00, 03, 00, 04, 00, 01, 01, 04, 03), "Vasques" => array(03, 01, 00, 03, 04, 07, 00, 01, 00, 07, 07) ); function cmp($a, $b) { return array_sum($b) - array_sum($a); } uasort($scores, "cmp"); //start loop for rows foreach($scores as $key=>$value) { echo $key . " " .array_sum($value) . "<br/>"; }
Output for 7.0.0 - 7.1.0
Mike 37<br/>Kyle 34<br/>Will 33<br/>Vasques 33<br/>Johnny 30<br/>
Output for 4.3.0 - 5.6.28
Mike 37<br/>Kyle 34<br/>Vasques 33<br/>Will 33<br/>Johnny 30<br/>