How to check if an integer is within a range?

前端 未结 8 806
轻奢々
轻奢々 2020-11-28 07:35

Is there a way to test a range without doing this redundant code:

if ($int>$min && $int<$max)

?

Like a function:

8条回答
  •  暖寄归人
    2020-11-28 07:55

    I don't think you'll get a better way than your function.

    It is clean, easy to follow and understand, and returns the result of the condition (no return (...) ? true : false mess).

提交回复
热议问题