Hi guys, I'm having trouble trying to build an array in PHP which will output in the JSON format I am looking for. I will show you what I am trying to achieve and where I have got to so far:
[
{"data":[{"x":3,"y":0},{"x":10,"y":0}]},
{"data":[{"x":11,"y":0},{"x":13,"y":0}]},
{"data":[{"x":12,"y":1},{"x":17,"y":1}]}
]
I am looping through db results and trying to build arrays to output the above json, my php looks like this (which is obviously not right yet):
//build the data
$data = array(
array(
'x' => $age_start,
'y' => $ill_type
),
array(
'x' => $age_end,
'y' => $ill_type
)
);
$illnesses[] = $data;
This code outputs the following json:
[
{
[
[{"x":2,"y":6},{"x":2,"y":6}],
[{"x":2,"y":6},{"x":5,"y":6}],
[{"x":4,"y":6},{"x":4,"y":6}]
]
}
]
Any pointers on this would be great!