switch case with if condition in php code example
Example 1: switch case php
switch (fruit) {
case apple:
code to be executed if fruit=apple;
break;
case banana:
code to be executed if fruit=banana;
break;
...
default:
code to be executed if fruit is different from all fruits;
}
Example 2: switch case php
$fruit = "apple";
switch ($fruit) {
case "apple":
echo "doctor";
break;
case "banana":
echo "monkey";
break;
default:
echo "things";
}
Example 3: switch case or case php
switch ($your_variable)
{
case 1:
case 2:
echo "the value is either 1 or 2.";
break;
}