I have the following dataset:
ToDo_Name List_ID
-------------------------------
Read book 1
Study English 2
Do excercises 2
Sleep 1
Eat 1
I need to group this data by List_ID creating the array like this (and send it as json to frontend):
$result = array(
array("listId" => 1, array('Read book', 'Sleep', 'Eat ')),
array("listId" => 2, array('Study English', 'Do excercises'))
);
I can't understand - should I do this using some SQL query or PHP array methods? Will be happy to hear any advices...