The switch statement is similar to a series of IF statements on the same expression. In many occasions, you may want to compare the same variable (or expression) with many different values, and execute a different piece of code depending on which value it equals to. This isĀ what the switch statement is for.
[php]
<?php
switch ($make) {
case "Ford":
echo "Your car is a Ford";
break;
case "Chevrolet":
echo "Your car is a Chevrolet";
break;
case "Toyota":
echo "Your car is a Toyota";
break;
}
?>
[/php]