How to check if an integer is within a range of numbers in PHP?

后端 未结 13 637
傲寒
傲寒 2020-12-04 10:57

How can I check if a given number is within a range of numbers?

13条回答
  •  醉梦人生
    2020-12-04 11:52

    The expression:

     ($min <= $value) && ($value <= $max)
    

    will be true if $value is between $min and $max, inclusively

    See the PHP docs for more on comparison operators

提交回复
热议问题