What is the purpose of the switch case statement in PHP?
The switch case statement in PHP is used to compare a variable against multiple values and execute different blocks of code based on the matching value. This is useful when you have multiple conditions to check against a single variable. Example:
$day = "Monday";
switch ($day) {
case "Monday":
echo "Today is Monday";
break;
case "Tuesday":
echo "Today is Tuesday";
break;
case "Wednesday":
echo "Today is Wednesday";
break;
default:
echo "Today is not Monday, Tuesday, or Wednesday";
}