PHP switch Statement

PHP switch Statement

In php switch statement is used to execute one code block out of many. Switch statement does almost the same thing to if-else if-else statement.

switch(a){
    case label1:
        // Code to be executed if a=1
        break;
    case label2:
        // Code to be executed if a=2
        break;
    ...
    default:
        // Code to be executed if n not matched with any labels
}