June 7, 2010
How to add multiple condition cases inside Switch method?
Question by Starx
Is there a way to include multiple cases inside a switch method in php?
Answer by Starx
Yes it is possible
Here is an example to start with
<?
$i = 1;
$j = 10;
switch($i) {
case "2":
echo "The value is 2";
break;
case ($i==1 && $j==10):
echo "Your exceptional Switch case is triggered";
break;
default:
echo "Invalid";
break;
}
?>