SWITCH statements can be used instead of multiple IF-ELSE statements checking for the same condition.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php #switch.php $test = 3; switch($test) { case 1: echo "this is case 1"; break; case 2: echo "this is case 2"; break; case 3: echo "this is case 3"; break; default: //use default for all other cases echo "No value specified for test var"; break; } ?> |
Click here to read about arrays.