<?php
$json = '[{
"book": [{
"name": "Harry Potter and the Goblet of Fire",
"author": "J. K. Rowling",
"year": 2000,
"genre": "Fantasy Fiction",
"bestseller": true
},{
"name": "The Load of The Ring",
"year": 2002,
"genre": "Fantasy Fiction",
"bestseller": true
}]
}]';
// Decode JSON data to PHP
$arr = json_decode($json, true);
print_r($arr);
echo "<hr>";
// Loop through the object
foreach($arr as $key => $val){
foreach($val as $a)
{
foreach($a as $b)
{
echo $b['name'].'<br>';
echo $b['year'].'<br>';
}
}
}