if in switch 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 php
switch ($element) {
case 0:
echo "i es igual a 0";
break;
case 1:
echo "i es igual a 1";
break;
case 2:
echo "i es igual a 2";
break;
}