PHP Switch Statements
Consider that you have many conditions, rather than doing "ifelse" you can use switch statements and php execute it faster than ifelse statements
Syntax
<?php
switch (conditions) {
case val1:
executed if conditions matched with val1.
break;
case val2:
executed if conditions matched with val2.
break;
default:
code to be executed if none of the above conditions satisfy.
}
?>
Example
<?php
$fruits = "Mango";
switch ($fruits) {
case "Grapes":
echo "I Like Grapes";
break;
case "Mango":
echo "I Like Mango";
break;
case "Orange":
echo "I Like Orange";
break;
default:
echo "No fruits for me.";
break;
}?>
//Output: I Like Mango


