blob: 9bc889f7706b929ff88492c4a5c473968703197f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
<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>
|