I have some data stored in a table like so:
id parent_id name
1 0 Entry 1
2 0 Entry 2
3 0 Entry 3
4 1 Child of entry 1
I want to turn it into a nested array like so:
array(
array(
'id' => 1,
'parent_id' => 0,
'name' => 'Entry 1',
'children' => array(...)
),
...
);
Ideally, it would need to support an infinite amount of nesting (children with children). Is my table set up to support this, if so, how would I generate this kind of array using the data in the table? If not, how should I set up my table?