if($number <= 300 || $number > 840 || (($number-1) % 100) >= 40) {
echo "Number was not in ranges!";
}
This takes advantage of the %
(modulo) operator which returns the remainder when dividing by a number - so since you're wanting numbers where the remainder modulo 100 is 1-40, it can just subtract one, take it modulo 100, and then see if that is 40+ (since 1-40 is now 0-39).
This approach is nice and concise, as long as your ranges follow that set pattern. If you need more customization of the individual ranges, use a switch
statement (see the answer from "too much php" for an example of this).