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

Switch case in PHP is used to simplify the process of checking multiple conditions and executing different blocks of code based on those conditions. It is a more efficient and cleaner way to handle multiple if-else statements. By using switch case, you can easily compare a variable against multiple values and perform different actions accordingly.

$color = "red";

switch($color) {
    case "red":
        echo "The color is red.";
        break;
    case "blue":
        echo "The color is blue.";
        break;
    case "green":
        echo "The color is green.";
        break;
    default:
        echo "The color is not red, blue, or green.";
}