I have this Json array events
[
{
"id": "4",
"event_name": "Harliquins 7s",
"event_description": "Ruggby game",
"event_date": null,
"event_venue": "UFA grounds",
"event_company": "Harliquins",
"event_image": "http://www.aal-europe.eu/wp-content/uploads/2013/12/events_medium.jpg",
"event_ticket_no": "200",
"paybill": "25666",
"status": "0"
},
{
"id": "5",
"event_name": "christie &s",
"event_description": "Ruggby",
"event_date": "1-2-2917",
"event_venue": "KISUMU ground",
"event_company": "Kenya Games",
"event_image": "N/A",
"event_ticket_no": "400",
"paybill": "79000",
"status": "0"
}
]
I also have this options
[
{
"id": "4",
"event_id": "5",
"options_id": "1",
"seasonal": "1",
"amount": "300"
},
{
"id": "5",
"event_id": "5",
"options_id": "2",
"seasonal": "1",
"amount": "400"
}
]
I want to get this as the results
[
{
"id": "4",
"event_name": "Harliquins 7s",
"event_description": "Ruggby game",
"event_date": null,
"event_venue": "UFA grounds",
"event_company": "Harliquins",
"event_image": "http://www.aal-europe.eu/wp-content/uploads/2013/12/events_medium.jpg",
"event_ticket_no": "200",
"paybill": "25666",
"status": "0"
},
{
"id": "5",
"event_name": "christie &s",
"event_description": "Ruggby",
"event_date": "1-2-2917",
"event_venue": "KISUMU ground",
"event_company": "Kenya Games",
"event_image": "N/A",
"event_ticket_no": "400",
"paybill": "79000",
"status": "0",
"Options:" [
{
"id": "4",
"event_id": "5",
"options_id": "1",
"seasonal": "1",
"amount": "300"
},
{
"id": "5",
"event_id": "5",
"options_id": "2",
"seasonal": "1",
"amount": "400"
}
]
}
]
Here is my code:
while( $row = $result->fetch_assoc()){
$new_array[] =$row;
$new_array['options'] =getTicketOptions($row['id']);
}
echo json_encode($new_array);
Each event object has an option array.