What is the purpose of using a switch statement in PHP?

Switch statements in PHP are used to simplify code that involves multiple conditional statements. Instead of writing multiple if-else statements, a switch statement allows you to compare a single value against multiple possible values and execute different blocks of code based on the matching value. This can make the code more readable and easier to maintain, especially when dealing with a large number of possible conditions.

$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";
}