How do I find out if a number is between or equal to. Lets say x=333. How do I tell if it's between or eqqual to 300-500.
if (($val >= 300) && ($val <= 500)) {echo $val . " is within the range";} else {echo $val . " is out of range";}
Thanks. Is that comparison allowed in a switch statement or should I use an IF statement
As a switch statement:
switch($var) { case($var = ""): echo "enter a number"; break; case($var <= 299): echo "$var is too low"; break; case($var >= 501): echo "$var is too high"; break; default: echo "within the range of 300 - 500"; }
um... I just noticed that the Switch code doesn't work.
Is it fixable?
Change case($var = ""):
to case($var == ""):
notive the second equal sign
cooooool - it works! as a further refinement:
case($var == " "):
(notice the space between the quotes)
thanx sooo much! there's such a wealth of talent on this forum!
or you could've use
case(empty($var)):