Previously I was using a foreach loop to access the data in my JSON object but now I have nested an array inside an array. Here is my JSON
{
"name": "Takeaway Kings",
"menu": [
{
"starter": [
{
"name": "Samosas",
"price": 3.5
},
{
"name": "Chaat",
"price": 1.99
}
]
},
{
"dessert": [
{
"name": "Kulfi",
"price": 2.5
},
{
"name": "Kheer",
"price": 2.99
}
]
},
{
"main": [
{
"name": "Lamb Biryani",
"price": 4.5
},
{
"name": "Chicken Tikka Masala",
"price": 5.99
}
]
}
]
}
I am trying to loop through each array inside menu and then loop through what is in each nested array.
I was previously using this to output data before I changed the JSONObject layout.
<?php foreach($restaurant->menu->starter as $starter){
echo '<h3>'.$starter->name.'</h3><br><p>'.$starter->price.'</p><br>';
} ?>