Posted by Ewoud Dronkert on 10/14/05 20:24
Ed wrote:
> FYI - The way you have nested the lists is invalid. A nested list can
> only be inside another list element :)
Damn, that's right! Then how about:
function makelist($a)
{
static $level = 0;
$open = FALSE;
++$level;
$tab = str_repeat("\t", $level);
$html = "<ul>\n";
foreach ( $a as $item )
{
if ( is_array($item) )
$html .= makelist($item);
else
{
if ( $open )
$html .= "</li>\n";
else
$open = TRUE;
$html .= "$tab<li>$item";
}
}
if ( $open )
$html .= "</li>";
$html .= "</ul>";
--$level;
return $html;
}
--
E. Dronkert
[Back to original message]
|