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

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

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

13条回答
  •  庸人自扰
    2020-12-04 11:38

    if (($num >= $lower_boundary) && ($num <= $upper_boundary)) {
    

    You may want to adjust the comparison operators if you want the boundary values not to be valid.

提交回复
热议问题