diff --git a/index.php b/index.php index d3130b4..89c2d1c 100644 --- a/index.php +++ b/index.php @@ -3,10 +3,22 @@ $jsonData = file_get_contents('data/player_matches.json'); $playersData = json_decode($jsonData, true); -// Function to get the last 5 matches for a player -function getLastMatches($player) { - return array_slice($player['player_matches'], -5); +// Combine matches from all players +$allMatches = []; +foreach ($playersData as $player) { + foreach ($player['player_matches'] as $match) { + $match['playername'] = $player['playername']; // Add playername to each match for reference + $allMatches[] = $match; + } } + +// Sort matches by createdAt date +usort($allMatches, function($a, $b) { + return strtotime($b['createdAt']) - strtotime($a['createdAt']); +}); + +// Get the last 5 matches +$lastMatches = array_slice($allMatches, 0, 5); ?> @@ -27,8 +39,9 @@ function getLastMatches($player) {
+

Welcome to DTCH - PUBG Clan

- +
@@ -44,28 +57,25 @@ function getLastMatches($player) { - - - - - - - - - - - - + + + + + + + + + + + +
Match Date
-

Welcome to DTCH - PUBG Clan

+

Join us on our Discord: