Mar 16, 2007 #1 JMay0816 Programmer Mar 1, 2007 34 US Is there an easier way to code this: if $a==1 && $b==2 || $a==1 and $b==4 something like: if $a==1 && $b IN (2,4) don't know if PHP will allow to simply the if statement.
Is there an easier way to code this: if $a==1 && $b==2 || $a==1 and $b==4 something like: if $a==1 && $b IN (2,4) don't know if PHP will allow to simply the if statement.
Mar 16, 2007 #2 jpadie Technical User Nov 24, 2003 10,094 FR Code: if ( ( $a==1 ) && (in_array($b, array(2,4) )) or Code: if ($a==1){ if ($b==2 || $b==4){ } } Upvote 0 Downvote
Mar 16, 2007 #3 Itshim Programmer Apr 6, 2004 277 US Just for variety: Code: if ($a==1){ switch ($b) { case 2: case 4: //do something break; } } Upvote 0 Downvote