Is there a way test multiple cases in a switch statement?
For example cases 1 and 2 have the same result as do cases 3 and 4. This code works fine, just a bit tedious as the cases grow.
switch ($_GET['id']) {
case '1':
header("Location: /a.html");
break;
case '2':
header("Location: /a.html");
break;
case '3':
header("Location: /b.html");
break;
case '4':
header("Location: /b.html");
break;
default:
header("index.html");
break;
I would like to do something like the following, but I've had no luck. No matter what I pass as the id, I always get location a.
switch ($_GET['id']) {
case '1' OR '2':
header("Location: /a.html");
break;
case '3' OR '4':
header("Location: /a.html");
break;
default:
header("index.html");
break;