You are here: outputting multi-dim array « All PHP « IT news, forums, messages
outputting multi-dim array

Posted by Decavolt on 01/25/07 17:19

I'm building a nav structure in PHP that's using simplified XML files
to populate an unordered list. I have an xml parser that coverts my XML
to a multi-dimensional array, but I'm having issues getting by data out
of that array.

My xml file looks something like this:

<SECTION title="Search Engines">
<ITEM name="Google" url="www.google.com" />
<ITEM name="Yahoo" url="www.yahoo.com" />
</SECTION>
<SECTION title="Boogers">
<ITEM name="Slimy" url="slimy.com" />
<ITEM name="Crunchy" url="crunchy.com" />
</SECTION>

I'm very used to using a for loop over single-dim arrays but not so
much on mult-dim arrays. I'd like to output something like this:

<li class="title">Search Engines</li>
<li><a href="www.google.com">Google</a></li>
<li><a href="www.yahoo.com">Yahoo</a></li>
<li class="title">Boogers</li>
<li><a href="slimy.com">Slimy</a></li>
<li><a href="crunchy.com">Crunchy</a></li>

I've been looking at examples and pouring over php.net's docs to no
avail, and can't seem to get a loop structure that'll output what seems
like a very simple multi-dim array structure.
Can anyone point me in the right direction for that loop, or suggest a
better way for me to go about this?

 

Navigation:

[Reply to this 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

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