SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Feb 2009
    Location
    Austin Texas
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Looping Nested unordered list for menu (arrays)

    I'm confused as to how to use an associative array to produce a menu with a nested UL. For example, the result I'd like to achieve is:
    Code:
    <ul>
    <li><a href="page1.html">Page 1</a></li>
    <li><a href="page2.html">Page 2</a>
       <ul>
         <li><a href="page2-1.html">Page 2-1</a></li>
         <li><a href="page2-2.html">Page 2-2</a></li>
         <li><a href="page2-3.html">Page 2-3</a></li>
    	</ul>
    </li>
    <li><a href="page3.html">Page 3</a></li>
    </ul>
    I can get my head around using an array like
    Array("page1.html"=>"Page 1", "page2.html"=>"Page 2");
    but I wouldn't know how to end the nested UL or where to store the value for Page 2, for example, when creating the menu.

    Any ideas?

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Maybe this post would help you on your way?
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Addict
    Join Date
    Feb 2009
    Location
    Austin Texas
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, stellar. Thanks! But what if Categories or Biscuits in your example is a link rather than just an empty anchor?


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •