jaikar Posted September 16, 2007 Share Posted September 16, 2007 Hi .. is there any alternative to the below code?. if($flag == 1 || $flag == 2 || $flag == 3) { do someting } else { do something else } is there anything like $flag == 1 || 2 || 3 ?... will this work ? please advice.. Thanks ~J Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted September 16, 2007 Share Posted September 16, 2007 Nope, the way you are doing it is the correct way =] This One: <?php if($flag == 1 || $flag == 2 || $flag == 3) { //do someting } else { //do something else } ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 16, 2007 Share Posted September 16, 2007 if it's a lot more than that, make an array and use in_array() Quote Link to comment Share on other sites More sharing options...
rarebit Posted September 16, 2007 Share Posted September 16, 2007 Not really but: if ($x >= 1 && $x <= 3) { } Quote Link to comment Share on other sites More sharing options...
jaikar Posted September 16, 2007 Author Share Posted September 16, 2007 Thankyou for the ideas ! ~J Quote Link to comment 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.