Rangsystem in PHP?

... komplette Frage anzeigen

2 Antworten

$rankings = [
[
"user" => "User 1",
"punkte" => 80
],
[
"user" => "User 2",
"punkte" => 100
],
[
"user" => "User 3",
"punkte" => 75
],
[
"user" => "User 4",
"punkte" => 20
],
];

usort($rankings, function($a, $b) {
return $a["punkte"] - $b["punkte"];
}); print_r($rankings);

Ergebnis

Array
(
[0] => Array
(
[user] => User 4
[punkte] => 20
)

[1] => Array
(
[user] => User 3
[punkte] => 75
)

[2] => Array
(
[user] => User 1
[punkte] => 80
)

[3] => Array
(
[user] => User 2
[punkte] => 100
)
)
Antwort bewerten Vielen Dank für Deine Bewertung

Was möchtest Du wissen?