Code: Select all
$depth = 0;
foreach($this->items as $item){
if($item['depth'] > $depth){
echo '<ul>';
}
else{
echo '</ul>';
}
echo '<li>';
echo $item['label'];
echo '</li>';
//if($item['depth'] < $depth){
// echo '</ul>';
//}
$depth = $item['depth'];
}The idea is simple enough , I have an array such like:
Code: Select all
name, label, depth
------------------
Alex, Manager, 0
Sean, Contractor, 1
Mike, Contractor, 1
Sara, Specialist, 2
John, Developer, 0Code: Select all
Alex
Sean
Mike
Sara
JohnCode: Select all
name, label, depth
------------------
Alex, Manager, 0
Sara, Specialist, 2
John, Developer, 0
Sean, Contractor, 1
Mike, Contractor, 1
Anyways, Ive had it with this this problem...Iève spent to much time in the lofty heavens thinking about abstractions, architecture, etc...now my brain will not comprehend low-level implementation details, anything beyond tying to gather interfaces, etc.
Ièm actually implementing my 2nd (or 7th) attempt but still curious to see if anyone can come up with something more clever or efficient.
Please no recursion or conversion of the linear array to a structured array, then converting the nested array into this XHTML markup...this might be a last resort technique, so unless you really have to, Ièm still interested in seeing how you might convert a linear array into something nested.
Cheers,
Alex