Forum Moderators: coopster

Message Too Old, No Replies

? aboult a compouned IF( )

&& , ¦¦ and ==

         

Sarah Atkinson

5:04 pm on May 20, 2005 (gmt 0)

10+ Year Member



How would you write a conditional statment that executes when $x==5 and $y==4 or when $x==9 and $y==4?

dreamcatcher

6:22 pm on May 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe:

if (($x==5 && $y==4) ¦¦ ($x==9 && $y==4))
{
//do something
}

If its only $x thats changing, you can also use a switch statement:

switch ($x)
{
case 5:
//do something
break;

case 9:
//do something
break;
}

dc

StuffOfInterest

6:58 pm on May 20, 2005 (gmt 0)

10+ Year Member



For your case above, another variant would be:

if ($y == 4 && ($x == 5 ¦¦ $x == 9)) {
//do something
}