CircularStopSign Posted September 5, 2006 Share Posted September 5, 2006 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 && Quote Link to comment https://forums.phpfreaks.com/topic/19827-multiple-condidtions-in-an-if-statement/ Share on other sites More sharing options...
wildteen88 Posted September 5, 2006 Share Posted September 5, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/19827-multiple-condidtions-in-an-if-statement/#findComment-86738 Share on other sites More sharing options...
roopurt18 Posted September 5, 2006 Share Posted September 5, 2006 if( $one || $two || $three ){ echo "hi2u";} Quote Link to comment https://forums.phpfreaks.com/topic/19827-multiple-condidtions-in-an-if-statement/#findComment-86739 Share on other sites More sharing options...
CircularStopSign Posted September 5, 2006 Author Share Posted September 5, 2006 alright thanks... i was thinking something like that, but i wasnt sure. i think its the same in JS right? Quote Link to comment https://forums.phpfreaks.com/topic/19827-multiple-condidtions-in-an-if-statement/#findComment-86740 Share on other sites More sharing options...
roopurt18 Posted September 5, 2006 Share Posted September 5, 2006 Most languages that share the c-style syntax use:|| for OR&& for AND! for NOT Quote Link to comment https://forums.phpfreaks.com/topic/19827-multiple-condidtions-in-an-if-statement/#findComment-86742 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.