PHP - switch


]Podporované v PHP 4, PHP5 

Popis

Príkaz jazyka PHP
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 exactly what the switch statement is for.

Príklad

<?php
switch ($i) {
    case 0:
        echo "i je 0";
        break;
    case 1:
        echo "i je 1";
        break;
    case 2:
        echo "i je 2";
        break;
    default:
       echo "i nie je 0, 1 ani 2";
}
?>


]