Up until now I have just used PHP's json_encode() on simple rows of data, for example
{
"name":"bob",
"age":"22"
}
However I have the need to return JSON which has arrays.
Example output is
{
"success":true,
"payload":
{
"venuedata":
{
"id":"1",
"name":"venue name"
},
"menus": [
{"menuid":"1","menuname":"food","items": [{"item":"pizza","cost":"$12.50"},{"item":"burger","cost":"$14.50"}]},
{"menuid":"2","menuname":"drinks","items": [{"item":"pint of beer","cost":"$5.50"}]}
]
}
}
Now, the venuedata object will come from one PDO query, and the menus will come from another query and the items for each menu will come from another query.
How can I use json_encode to return the example JSON?