Version: 1.5
Type: Sample Code (HOWTO)
Category: Other
License: GNU General Public License
Description: Create a menu based on an array.
<? /************************************************* * This code snippet is copyrighted to ThinkGFX.com * * Use this array to store all the links on the menu * on your website. * On the array, the data on the left is the name of * the link. The one on the right is the link. * Just edit it, remove or add more links. You don't * need to edit anything else, unless you want to * improve it. * I hope you enjoy using this array and you like it. * Please leave copyright intact. * **************************************************/ // Here is the array with all the data: $menu = array( "Home" => "index.php", "Products" => "products.php", "Services" => "services.php", "Support" => "support.php", "About Us" => "about_us.php", "Contact Us" => "contact_us.php", ); // Below will generate the menu based on the array. echo "<h3>Menu</h3><br>"; foreach($menu as $name => $link) { echo "<a href='$link'>$name</a><br>"; } // End. ?>