|
Posted by Oliver Saunders on 10/14/05 14:11
> function makelist($a)
> {
> static $level = -1;
>
> ++$level;
> $spc = str_repeat(' ', 2 * $level);
> $html = "$spc<ul>\n";
> foreach ( $a as $i )
> {
> if ( is_array($i) )
> $html .= makelist($i);
> else
> $html .= "$spc <li>$i</li>\n";
> }
> $html .= "$spc</ul>\n";
>
> --$level;
> return $html;
> }
>
> echo makelist($notes));
Shame about the extra parentesis on your last line. But i'm willing to
let that go.
The solution is elegant, flexible, compact and I especially like the way
you put in the whitespace as well. You, my friend, have won yourself a
can of sardines and my respect as an excellent PHP programmer. Well Done!
What's the address you would like them delievered then?
Navigation:
[Reply to this message]
|