Reply to Re: PHP Array Challenge!

Your name:

Reply:


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?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация