GRooVeZ Posted May 18, 2012 Share Posted May 18, 2012 if u use this for one condition if ($nr > 5) how would u check if the nr is between 5 and 50 thx ! Quote Link to comment https://forums.phpfreaks.com/topic/262748-double-condition/ Share on other sites More sharing options...
QuickOldCar Posted May 18, 2012 Share Posted May 18, 2012 if ($nr > 5 && $nr < 50) Quote Link to comment https://forums.phpfreaks.com/topic/262748-double-condition/#findComment-1346695 Share on other sites More sharing options...
scootstah Posted May 18, 2012 Share Posted May 18, 2012 Just to be different... if (in_array($nr, range(5,50))) Quote Link to comment https://forums.phpfreaks.com/topic/262748-double-condition/#findComment-1346699 Share on other sites More sharing options...
GRooVeZ Posted May 18, 2012 Author Share Posted May 18, 2012 thx ! Quote Link to comment https://forums.phpfreaks.com/topic/262748-double-condition/#findComment-1346701 Share on other sites More sharing options...
Alex Posted May 19, 2012 Share Posted May 19, 2012 Just to be different... if (in_array($nr, range(5,50))) The OP wanted it to be 5-50 exclusive, so you'd need to do range(6, 49). But even then this would only work if $nr can only have integer values. For decimals it wouldn't work. Quote Link to comment https://forums.phpfreaks.com/topic/262748-double-condition/#findComment-1346728 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.