Jump to content

Archived

This topic is now archived and is closed to further replies.

CircularStopSign

multiple condidtions in an if statement

Recommended Posts

how would i say:

if(stuff==array[0] or array[1] or array[2]){
echo "Stuff is equal too 0,1, and 2";
}
haha sounds kind of childish but i cant find it anywhere i can only find &&

Share this post


Link to post
Share on other sites
Use:
[code=php:0]if($var == $array[0] || $var == $array[1] || $var == $array[2])
{
    echo "Stuff is equal too 0,1, and 2";
}[/code]


How ever what you'll probably want to use is in_array:
[code=php:0]if(in_array($var, $array)
{
    echo ;    echo "$var us in the array!";
}[/code]

Share this post


Link to post
Share on other sites
Most languages that share the c-style syntax use:

|| for OR
&& for AND
! for NOT

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.