在多个案例中运行切换案例功能?

switch(n){
case "badge01":
case "badge02":
case "badge03":
case "badge04":
case "badge05":
//dosomething
     break;
}

Hi above's switch case statement, I would like to use a function to run the multiple loop to generate the case's name, so can i know how to generate with function on a switch case statement like this?

switch(n){
case badgenameloop():
//dosomething
     break;
}

And is it possible to do that?

Thanks and sorry for my bad English.

According to PHP Manual

The case expression may be any expression that evaluates to a simple type, that is, integer or floating-point numbers and strings. Arrays or objects cannot be used here unless they are dereferenced to a simple type.

I'm afraid you can Not have a Loop for a case statement, hence a waste of time trying.

You can do this for example:

function badgenameloop($key)
{
    switch($key){
        case "badge01":
        case "badge02":
        case "badge03":
        case "badge04":
        case "badge05":
            echo "badge 1";
            break;
    }
}

function badgename2loop($key)
{
    switch($key){
        case "badge_2_01":
        case "badge_2_02":
        case "badge_2_03":
        case "badge_2_04":
        case "badge_2_05":
            echo "badge 2";
            break;
    }
}

$key = "badge_2_01";
switch($key){
    case badgenameloop($key): break;
    case badgename2loop($key): break;
}