[PHP] How do I stop foreach if $menu not set??
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 .= lia href='.$link.'.$name./a/libr; ? a href=?menu=introductionIntroduction/abr ? $introduction; ?br a href=?menu=supportSupport/abr ? $support; ? - Daniel Broome, siliconBLUE Ltd, Web Author, http://siliconblue.com Mob: 64-21-178-5120 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I stop foreach if $menu not set??
Change introduction to a variable with $ in front of it or put it in quotes introduction. 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' ); } This message is intended for the sole use of the individual and entity to whom it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not the intended addressee, nor authorized to receive for the intended addressee, you are hereby notified that you may not use, copy, disclose or distribute to anyone the message or any information contained in the message. If you have received this message in error, please immediately advise the sender by reply email and delete the message. Thank you very much. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I stop foreach if $menu not set??
On Tuesday, June 11, 2002 at 10:59:13 PM, you wrote: 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?? http://www.php.net/isset -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I stop foreach if $menu not set??
You should be able to contain your foreach statement within an if statement: if (isset($menu)) { foreach ($sub as $link = $name) ( $sublink .= lia href='.$link.'.$name./a/libr; } else { print menu variable not set } Hope this helps. Hugh - Original Message - From: Dan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, June 11, 2002 2:59 PM Subject: [PHP] How do I stop foreach if $menu not set?? 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 .= lia href='.$link.'.$name./a/libr; ? a href=?menu=introductionIntroduction/abr ? $introduction; ?br a href=?menu=supportSupport/abr ? $support; ? - Daniel Broome, siliconBLUE Ltd, Web Author, http://siliconblue.com Mob: 64-21-178-5120 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php