Problem: This is all about ranking. This rank should contain numbers from zero up to ten. However, I notice that the sum of my array that stores the values are not entering numbers higher than 07. So, it can only sums the number from 00 up to 07! I couldn't find the mistake.
Code:
<tbody>
<?php
$scores = array(
"Kyle" => array("-", 04, 04, 06, 04, 05, 04, 04),
"Bill" => array("-", 04, 09, 04, 07, 08, 04, 10),
"Adam" => array("-", 04, 04, 04, 01, 04, 04, 04),
"Johnny" => array("-", 08, 04, 10, 04, 08, 08, 04),
?>
###function to return the sum
function cmp($a, $b) {
return array_sum($b) - array_sum($a);
}
####sort the ranking into the td
uasort($scores, "cmp");
foreach($scores as $key=>$value) {
echo "<tr>";
echo "<th>$key</th>";
echo "<td class='total' align='center' valign='middle'>" . array_sum($value) . "</td>";
for($x=0; $x<count($value); $x++) {
echo "<td class='games tip' align='center' valign='middle'>".sprintf('%02d', $value[$x])."</td>";
}
echo "</tr>";
}
?>
</tbody>
Thank you!