Hi. Can someone help me set up an array for a file I am using in navigation? The navigation is an unordered list, which will then get styled as tabs with CSS.
It needs to store 6 things.
1) The name of the link
2) The URL of each link
3) A sub link name, if there is one
4) The sub nav's URL
It should generate something like this:
Anyway a one dimensional array is easy. that would be this:Code:<ul id="primary"> <li><a href="main.html">Main Item 1</a></li> <li><a href="main2.html">Main Item 2</a> <ul id="secondary"> <li><a href="subnav">Sub</a></li> </ul> </li> </ul>
But how would I create an array that would also hold sub nav items and their hrefs?Code:<?php $nav_items = array( "Home" => "index.php", "Resources" => "resources.php", "Help" => "help.php", "About NCBI" => "about.php" ); echo "<ul id=\"primary\">\n"; foreach ($nav_items as $txt => $url) { echo "\t<li><a href=\"$url\">$txt</a></li>\n"; } echo "</ul>"; ?>


Reply With Quote
Bookmarks