I have an array with the following keys
id parent_id name
A sample array:
array(7) { [0]=> array(3) { [\"id\"
You can use FlatToTreeConverter class from Gears helper library:
$row) { $indexed[$row[$parentIdKey]][$childNodesField][$id] = &$indexed[$id]; if (!$row[$parentIdKey]) { $root[$id] = &$indexed[$id]; } } return $root; } }