PHP function generate UL LI
- by apis17
hi..
i'm referring this address for function olLiTree
http://stackoverflow.com/questions/753853/php-function-that-creates-a-nested-ul-li
i have this array
$tree =
array("A"=array("B"=array("C"="C","D"="D"),"E"=array("F"="F","G"="G")));
but not able to use this function
function olLiTree($tree)
{
echo '<ul>';
foreach($tree as $item) {
if (is_array($item)) {
olLiTree($item);
} else {
echo '<li>', $item, '</li>';
}
}
echo '</ul>';
}
to generate
<ul>
<li>A</li>
<li>B
<ul>
<li>C</li>
<li>D</li>
</ul>
</li>
<li>E
<ul>
<li>F
</li>
</ul>
</li>
<ul>
<li>G</li>
</ul>
</ul>
can anybody help me to fix this?
thanks..