This commit is contained in:
Lanta 2023-11-14 20:57:45 +01:00
parent 3a78be1ae4
commit e275f2748c

View file

@ -17,20 +17,20 @@ if (isset($_GET['matchid'])) {
echo "<tr><th>Player Name</th><th>Kills</th><th>Damage Dealt</th><th>Time Survived</th><th>Rank</th></tr>"; echo "<tr><th>Player Name</th><th>Kills</th><th>Damage Dealt</th><th>Time Survived</th><th>Rank</th></tr>";
// Loop through the JSON data to extract player stats // Loop through the JSON data to extract player stats
foreach ($jsonData['data']['relationships']['rosters']['data'] as $roster) {
foreach ($jsonData['included'] as $includedItem) { foreach ($jsonData['included'] as $includedItem) {
if ($includedItem['type'] === 'participant' && in_array(['type' => 'participant', 'id' => $includedItem['id']], $roster['relationships']['participants']['data'])) {
$playerStats = $includedItem['attributes']['stats']; $playerStats = $includedItem['attributes']['stats'];
echo "<tr>"; echo "<tr>";
echo "<td>" . htmlspecialchars($playerStats['name']) . "</td>"; echo "<td>" . htmlspecialchars($playerStats['name']) . "</td>";
echo "<td>" . htmlspecialchars($playerStats['kills']) . "</td>"; echo "<td>" . htmlspecialchars($playerStats['kills']) . "</td>";
echo "<td>" . htmlspecialchars($playerStats['damageDealt']) . "</td>"; echo "<td>" . htmlspecialchars($playerStats['damageDealt']) . "</td>";
echo "<td>" . htmlspecialchars($playerStats['timeSurvived']) . "</td>"; echo "<td>" . htmlspecialchars($playerStats['timeSurvived']) . "</td>";
echo "<td>" . htmlspecialchars($playerStats['winPlace']) . "</td>"; echo "<td>" . htmlspecialchars($playerStats['winPlace']) . "</td>";
echo "</tr>"; echo "</tr>";
}
}
} }
echo "</table>"; echo "</table>";
} else { } else {
echo "JSON file not found for the given match ID."; echo "JSON file not found for the given match ID.";