Lei Lionel Lei Lionel - 1 year ago 75
PHP Question

Verify if a value is included between two numbers

I am working with PHP and I want to verify if a specific number is between 2 numbers and if it returns

then we display a message

if($number is between $value1 and $value2){
echo 'Ok';
echo 'not Ok';

can be

Answer Source
function isBetween($number, $value1, $value2) {
    return $number >= $value1 && $number <= $value2;

. . . .

if(isBetween(1, 0.5, 2.5))
   echo "Ok";
   echo "Not Ok";

Pretty self-explanatory

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download