hi all..
let's say i have an array that looks like this:
$tasks[] = array(id => 1, parent_id => 0, title => 'task 1');
$tasks[] = array(id => 2, parent_id => 1, title => 'sub task 1');
$tasks[] = array(id => 3, parent_id => 1, title => 'sub task 2');
$tasks[] = array(id => 4, parent_id => 2, title => 'sub sub task 1');
$tasks[] = array(id => 5, parent_id => 0, title => 'task 2');
$tasks[] = array(id => 6, parent_id => 5, title => 'sub task 3');
now i would like to create a function, which would show me a treeview for this array. i know it should look something like this:
function treeview($id = NULL, $parent_id = NULL, $array)
{
for ($i = 0; $i < count($array); $i++)
{
// here, i'm lost...
// please help me out..
// we should now, recursively call the same function..
treeview($array[$i]['id'], $array[$i]['parent_id'], $array);
}
}
please help me out... 😢
thanks..