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.
0
give a positive ratinggive a negative rating
04 Dec 2020 at 08:43 AM
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;
}

0
give a positive ratinggive a negative rating
09 Dec 2020 at 10:23 AM
Tim
Share on FacebookShare on TwitterShare on LinkedInSend email
x
x
Follow us on Facebook
2022 AnswerTabsTermsContact us