I have some data that I need to organize so I could convert it to JSON. I get the data through a query which gives me the results. Some of the results are :
NAME - NUMBER, Direction, Color
ABCD - 1, Left, Blue
ABCD - 2, Right, Red
ABCD - 3, Down, Green
EFGH - 1, UP, Yellow
EFGH - 2, Down, Orange
And I need to convert that data into something like this (so I could json_encode it):
$array = array({
'name'=>'ABCD'
[{ 'number'=>'1', 'direction'=>'left', 'color'=>'blue'}
{ 'number'=>'2', 'direction'=>'right', 'color'=>'red' }
{ 'number'=>'3', 'direction'=>'down', 'color'=>'green' }
]}
{ 'name'=>'EFGH'
[{ 'number'=>'1', 'direction'=>'up', 'color'=>'yellow' }
{ 'number'=>'2', 'direction'=>'down', 'color'=>'orange' }
]}
);
Not sure if it's correctly done, but I guess how the results should be.