calmchess Posted March 12, 2009 Share Posted March 12, 2009 how do i write a statement that says if a number is between 1-4 but not 0 and not greater than 750 something like if($var0 == 1 through 4 || $var0>750){ //do this stuff} Quote Link to comment https://forums.phpfreaks.com/topic/149146-less-than-1-4-conditonal-statement-help/ Share on other sites More sharing options...
jackpf Posted March 12, 2009 Share Posted March 12, 2009 <?php if($var > 1 && $var < 4 && $var != 0 && $var <= 750) { //do whatever } ?> Is that good? Quote Link to comment https://forums.phpfreaks.com/topic/149146-less-than-1-4-conditonal-statement-help/#findComment-783147 Share on other sites More sharing options...
calmchess Posted March 12, 2009 Author Share Posted March 12, 2009 thanks Quote Link to comment https://forums.phpfreaks.com/topic/149146-less-than-1-4-conditonal-statement-help/#findComment-783170 Share on other sites More sharing options...
premiso Posted March 12, 2009 Share Posted March 12, 2009 You do realize that the first 1 through 4 will counteract anything else. As nothing else would "mount to true". If $var is between 1 and 4 is not going to be 0 or greater than 750...Basically you only need the greater than 1 and the less than 4. Quote Link to comment https://forums.phpfreaks.com/topic/149146-less-than-1-4-conditonal-statement-help/#findComment-783177 Share on other sites More sharing options...
Philip Posted March 12, 2009 Share Posted March 12, 2009 if a number is between 1-4 but not 0 and not greater than 750 Would if a number is between 1 and 4 automatically knock the other 2 qualifications out? If the number is 0, its not between 1 and 4, and if the number is 3, 3 isn't greater than 750, lol By the way, if you check if that number is between 1 and 4, including 1 and 4: if($var >= 1 && $var <=4) Quote Link to comment https://forums.phpfreaks.com/topic/149146-less-than-1-4-conditonal-statement-help/#findComment-783180 Share on other sites More sharing options...
jackpf Posted March 12, 2009 Share Posted March 12, 2009 Lol yeah, I didn't even think about it, I just wrote what he said to write. Yeah, how stupid of me, listen to these guys instead. Quote Link to comment https://forums.phpfreaks.com/topic/149146-less-than-1-4-conditonal-statement-help/#findComment-783281 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.