What do I have to write in the cases (of switch function in PHP) to make if $number > 0 && $number < 15?
I tried with:
<?php
$number = rand("0","100");
switch($number) {
case: $number > 0 && $number < 15;
$output = 1;
break;
case: $number > 15 && $number < 50;
$output = 2;
break;
}
return $output;
?>
Try the following. Your colons were in the wrong place!
From the comment by DaveRandom below. Be aware that nothing will happen if $number is equal to 15. I would recommend changing one of your
switchstatements. Perhaps by changing your first case into: