Php Switch statement is very useful, it works like if/else statement & reduce the complication of numerous conditions in the script.
Syntax :
switch (expression)
{
case 1
code .. //execute code if expression = 1
break;
case 2
code ... //execute code if expression = 2
break;
default:
code...//execute code if expression not matched
}
Example :<?php
$value = 6;
switch ($value)
{
case 1:
echo "Value 1";
break;
case 2:
echo "Value 2";
break;
case 3:
echo "Value 3";
break;
default:
echo "Value is " . $value . " not matched!";
}
?>