I am trying to get some data from an external API. From the JSON data I want to retrieve some data as marked in the image.
I can access the "teams" data by using this code -
foreach( $data->data as $info ) {
echo '<li class="team-1">'. $info->teams[0].'</li>';
echo '<li class="team-2">'. $info->teams[1].'</li>';
};
But when I try to access data more deep from array of objects it doesn't work & gives me error -
foreach( $info->sites as $site) {
foreach( $site->odds as $odd) {
echo $odd->h2h[0];
}
}
So my question is what is the best way to loop through the data to access these arrays. I am using this code in Wordpress but I think it will be same as PHP.

$site->odds->h2h[0]and$site->odds->h2h[1]