faqts : Computers : Programming : Languages : PHP : kms : General

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 15 people (87%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I make two cases in a switch do the same thing?
Does PHP switch work the same as C switch?

Aug 5th, 1999 22:41
Nathan Wallace, halim@admin1.mlcc.com.my, Rasmus Lerdorf, Aaron Leon Kaplan


PHP switch works basically the same as C switch.

    switch ($table) {
        case '1' : statement;
            break;
        case '2' : statement;
            break;
    }

To have two statements execute the same code simply do:

    switch ($table) {
        case '1':
        case '2':
             statement;
             break;
    }