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} 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? 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 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. 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 Quote 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) 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. 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
Archived
This topic is now archived and is closed to further replies.