jason360 Posted February 4, 2015 Share Posted February 4, 2015 Hey guys, I am not sure how to do a proper range in my if statement. I need a range where count is between 1 and 10. I am using this statement below, but it is just considering the $count<=10 and 0 is included in this statement. I require a different function for $count = 0. Thanks in advance! if ($count <= 10 && $count >= 1) Quote Link to comment https://forums.phpfreaks.com/topic/294389-number-range-in-if-statement/ Share on other sites More sharing options...
QuickOldCar Posted February 4, 2015 Share Posted February 4, 2015 if ($count <= 10 && $count >= 0){ if($count == 0){ //handle the 0 } else { //handle 1 to 10 } } Quote Link to comment https://forums.phpfreaks.com/topic/294389-number-range-in-if-statement/#findComment-1504901 Share on other sites More sharing options...
Solution Psycho Posted February 4, 2015 Solution Share Posted February 4, 2015 Or, if ($count == 0){ //handle the 0 } elseif ($count >= 1 && $count<=10) { //handle 1 to 10 } Quote Link to comment https://forums.phpfreaks.com/topic/294389-number-range-in-if-statement/#findComment-1504904 Share on other sites More sharing options...
jason360 Posted February 4, 2015 Author Share Posted February 4, 2015 Thanks Psycho and QuickOldCar! Quote Link to comment https://forums.phpfreaks.com/topic/294389-number-range-in-if-statement/#findComment-1504906 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.