Re: Complex IF statement
| From: | David Robley | Date: | Fri, 23 Mar 2001 05:26:35 +0000 |
| Subject: | Re: Complex IF statement | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-45249@lists.php.net to get a copy of this message | ||
On Wed, 13 Dec 2000 15:49, JCampbell wrote:
> Thank you all for your help earlier!
>
> Now I need to know if it is possible to create a complex if statement?
>
> if ($variable=="duck") || ($variable=="goose"){ }else{ }
>
> Is how I thought it would work. I just need to know if there is an easy
> way to do an OR in if statements IF variable equals duck or goose...
>
> <Jon>
Pretty much so; you might want to add extra parens thus:
if (($variable=="duck") || ($variable=="goose")){ }else{ }
You could, depending on exactly what you want, use a switch:
switch($variable){
case 'duck':
case 'goose':
duck or goose action;
break;
default:
elephants, tigers etc action;
}
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA