- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
function rawToStructuredDataTree($data) {
$structured_array = array();
foreach ($data as $cid => $node) {
$data[$cid]['children'] = array();
if ($node['parent_id'] == $cid || $node['parent_id'] == 0) {
$structured_array[$cid] = &$data[$cid];
} else {
$data[$node['parent_id']]['children'][$cid] = & $data[$cid];
}
}
return $structured_array;
}