Switch statement - multiple cases in cases with more conditions
How should I create a switch in PHP with multiple conditions in each case. I will also need to create a cases in these cases with more values included in conditions.
Hi,
To create a multiple switch cases in cases with more conditions, you can use something like this:
$value = 1;
switch ($value) {
case 1:
case 2:
switch ($value) {
case 1:
echo "<br /> Content A";
break;
case 2:
echo "<br /> Content B";
break;
}
echo "<br />Content C";
break;
case 3:
case 4:
echo "<br />Content D";
break;
}