36 lines
729 B
PHP
36 lines
729 B
PHP
|
<h1>Highscores</h1>
|
||
|
|
||
|
<?php
|
||
|
|
||
|
require_once(SITE_ROOT . "/models/" . "database.php");
|
||
|
$database = new Database();
|
||
|
$highscores = $database->getHighscores();
|
||
|
|
||
|
/*
|
||
|
* Sort multidimensional array according to $array[][1]
|
||
|
*/
|
||
|
|
||
|
$sortArray = array();
|
||
|
foreach ($highscores as $key => $value) {
|
||
|
$sortArray[$key] = $value[1];
|
||
|
}
|
||
|
array_multisort($sortArray, SORT_DESC, SORT_NUMERIC, $highscores);
|
||
|
|
||
|
$place = 0;
|
||
|
|
||
|
foreach ($highscores as $highscore) {
|
||
|
if ($highscore[1] <= 21) {
|
||
|
$place++;
|
||
|
}
|
||
|
if ($place != 0) {
|
||
|
echo "Place $place: ";
|
||
|
}
|
||
|
$score = round($highscore[1], 2);
|
||
|
echo" <b>$highscore[0]</b> with <b>$score</b> Points in <b>$highscore[2]</b> games<br />\n";
|
||
|
}
|
||
|
|
||
|
?>
|
||
|
|
||
|
<br /><br />
|
||
|
<a href="?menu">Back to menu</a>
|