Using comparison operators in a PHP 'switch' statement
Switches can't do that, but in this particular case you can do something like this:
switch ((int)(($count - 1) / 20)) {
case 0:
$priority = 'low';
break;
case 1:
$priority = 'medium';
break;
case 2:
$priority = 'high';
break;
case 3:
$priority = 'severe';
break;
}
So in (int)(($count - 1) / 20)
all values from 0 to 20 will eval to 0, 21 to 40 will eval to 1 and so on, allowing you to use the switch statement for this purpose.
And since we are concatenating values, we can even simplify to an array:
$priorities = ['low', 'medium', 'high', 'severe'];
$priority = $priorities[(int)(($count - 1) / 20)];
A more general case for solving this problem is:
switch (true) {
case $count <= 20:
$priority = 'low';
break;
case $count <= 40:
$priority = 'medium';
break;
case $count <= 60:
$priority = 'high';
break;
default:
$priority = 'severe';
break;
}