1
Sirs,
I am trying to access the values that are inside the house "values", recovering the value and the Odd but without success, I am creating so:
$json = json_decode($response);
foreach ($json->response as $item) {
echo $item->league->name . '<br>';
echo $item->league->country . '<br>';
foreach($item->bookmakers as $bets){
echo ' - ' . $bets->id . ' - ' . $bets->name . '<br>';
foreach ($bets->values as $odds) {
echo $odds->value;
echo $odds->odd;
}
}
}
my json
"response": [ {
"league": {
"id": 562,
"name": "Reserve League",
"country": "Belarus",
"logo": "https://media.api-sports.io/football/leagues/562.png",
"flag": "https://media.api-sports.io/flags/by.svg",
"season": 2020
},
"fixture": {
"id": 430126,
"timezone": "UTC",
"date": "2020-05-15T10:30:00+00:00",
"timestamp": 1589538600
},
"update": "2020-05-15T09:49:33+00:00",
"bookmakers": [
{
"id": 6,
"name": "Bwin",
"bets": [
{
"id": 1,
"name": "Match Winner",
"values": [
{
"value": "Home",
"odd": "1.90"
},
{
"value": "Draw",
"odd": "4.10"
},
{
"value": "Away",
"odd": "2.95"
}
]
}....
Where can I be missing?
Thank you.
I think it’s worth you posting yours
JSON
in text form here. Although it is not very big, the way it is you need another user to type it whole to be able to simulate your problem.– Andre
Edited question with JSON
– Cristiano Facirolli
You have to want to use one
for
in Bets, that’s inside bookmakers– Valdeir Psr
In the @Valdeirpsr case it would be like this for($Bets = 0; $Bets < Count($item->bookmakers); $Bets++){ echo $Bets; }
– Cristiano Facirolli