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.
04 Dec 2020 at 08:43 AM
0pnshow more
StorStor
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;
}

09 Dec 2020 at 10:23 AM
0pnshow more
TimTim
Share on FacebookShare on TwitterShare on LinkedInSend email
Follow us on Facebook & Twitter
2021 AnswerTabsTermsContact us