Use the switch statement to select one of many blocks of code to be executed.
This is significantly cleaner than writing a long, repetitive chain of if...elseif...else statements when comparing the exact same variable against multiple values.
switch expression is evaluated once.case.break keyword stops the execution inside the switch block.default statement is used if no match is found.<?php $favcolor = "red";switch ($favcolor) { case "red": echo "Your favorite color is red!"; break; case "blue": echo "Your favorite color is blue!"; break; case "green": echo "Your favorite color is green!"; break; default: echo "Your favorite color is neither red, blue, nor green!"; } ?>