How do I stop foreach if $menu not set??

From: Date: Tue, 11 Jun 2002 21:59:13 +0000
Subject: How do I stop foreach if $menu not set??
Groups: php.general 
Request: Send a blank email to php-general+get-101627@lists.php.net to get a copy of this message
I Have worked out this, but when $menu is not set it does the foreach function anyway, and desplays an error. What Can I do to stop the foreach function from working if $menu is not set?? <? if ($menu==(introduction)) {$sub = array( 'overview.php' => 'Overview', 'moreinfo.php' => 'More Info' ); } #These parts are topics and there may be more than two. if ($menu==(support)) {$sub = array( 'sitemap.php' => 'Site Map', 'contact.php' => 'Contact Us' ); } foreach ($sub as $link => $name) ( $sublink .= "<li><a href='".$link."'>".$name."</a></li><br>"; ?> <a href="?menu=introduction">Introduction</a><br> <? $introduction; ?><br> <a href="?menu=support">Support</a><br> <? $support; ?> ----------------------------------------- Daniel Broome, siliconBLUE Ltd, Web Author, http://siliconblue.com Mob: 64-21-178-5120

« previous php.general (#101627) next »