I have this array:
$data
stdClass Object(
[data] =>
Array(
[0] =>
stdClass Object(
[home_team] => Yantra Gabrovo
[away_team] => Septemvri Sofia
.....
[odds] =>
stdClass Object(
[1] => 3.17
[X] => 3.24
[2] => 2.2
[1X] => 1.6
[X2] => 1.31
[12] => 1.29
)
)
I want to insert data inside a simple html table so i create this:
$arr = json_decode($response, true);
echo '<table border=1>
<tr>
<th>ID</th>
<th>SQUADRA CASA</th>
<th>......</th>
<th>QUOTA 1</th>
<th>QUOTA X</th>
<th>QUOTA 2</th>
<th>QUOTA 1X</th>
<th>QUOTA X2</th>
<th>QUOTA 12</th>
</tr>';
foreach ($arr["data"] as list ("id" => $id, "home_team" => $home_team, "away_team" => $away_team, "start_date" => $start_date, "last_update_at" => $last_update_at, "1" => $quota1, "x" => $quotax, "2" => $quota2, "1x" => $quota1x, "x2" => $quotax2, "12" => $quota12 ))
{
echo "<tr>
<td>{$id}</td>
....
<td>{$quota1}</td>
<td>{$quotax}</td>
<td>{$quota2}</td>
<td>{$quota1x}</td>
<td>{$quotax2}</td>
<td>{$quota12}</td>
</tr>";
}
echo '</table>';
The problem is the array 0 contains another list called ODDS and if i try to call the data, is not showed that is nested and not show result 1, 2, x etc. Hope you can help me.
2
Answers
You need to do something like this: