How can the code snippet be optimized to avoid unnecessary if conditions?

The code snippet can be optimized by using a switch statement instead of multiple if conditions. This will make the code more readable and efficient as switch statements are designed for this type of scenario where multiple conditions need to be checked against a single variable.

// Optimized code using switch statement
$color = "blue";

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 "Unknown color";
}