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 && 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] 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";} 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? 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 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
Archived
This topic is now archived and is closed to further replies.