I have the following JSON:
{
"stars":5,
"numberOfReviews":{
"total":1179,
}
}
and the following PHP:
$json = file_get_contents('url-of-json');
$obj = json_decode($json);
print $obj->stars;
This prints 5
as expected. How do I print the "total" value of 1179
from the second level in the array's hierarchy?
I've been unable to find an explanation on how to achieve this. Here's some example of what I've been trying so far:
print $obj->total
print $obj->{'numberOfReviews', 'total'}
print $obj->['numberOfReviews']['total']
print $obj->numberOfReviews{'total'}
print $obj->[1]['total']
print $obj->numberOfReviews[0]total
print $obj->total[1]