Hallo zusammen,
ich möchte mit meinem PHP Code die aktuellen Bundesligaspiele zusammen mit den Ergebnissen von der URL "https://www.openligadb.de/api/getmatchdata/bl1/2018/1" abfragen. Bei den Teamnamen funktionert das auch ganz normal, wenn ich allerdings das Ergebnis abfragen will erhalte ich jedesmal die Fehlermeldung: "Notice: Undefined index: MatchResult in C:\xampp\htdocs\footballexpert\index.php on line 38". Mein Code sieht so aus:
Weiß vielleicht jemand wie ich dieses Problem lösen kann ?
Grüsse Christian
ich möchte mit meinem PHP Code die aktuellen Bundesligaspiele zusammen mit den Ergebnissen von der URL "https://www.openligadb.de/api/getmatchdata/bl1/2018/1" abfragen. Bei den Teamnamen funktionert das auch ganz normal, wenn ich allerdings das Ergebnis abfragen will erhalte ich jedesmal die Fehlermeldung: "Notice: Undefined index: MatchResult in C:\xampp\htdocs\footballexpert\index.php on line 38". Mein Code sieht so aus:
PHP-Code:
<?php
$matchCount = 34;
$current = 1;
$error = false;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.openligadb.de/api/getmatchdata/bl1/2018/1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$matches = json_decode($output, true);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>FootballExpert</title>
</head>
<body>
<h1>FootballExpert</h1>
<div>
<table>
<thead>
<tr>
<th>Begegnung</th>
<th>Ergebnis</th>
</tr>
</thead>
<tbody>
<?php
foreach ((array)$matches as $match) {
?>
<tr>
<td><?php echo $match["Team1"]["TeamName"]." - ".$match["Team2"]["TeamName"]; ?></td>
<td><?php echo $match["MatchResults"]["MatchResult"]["PointsTeam1"]." : ".$match["MatchResults"]["MatchResult"]["PointsTeam2"]; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</body>
</html>
Grüsse Christian
Kommentar