0

グループ ID の文字列または多数のグループ ID の配列のいずれかである変数があります。それらがグループに属しているかどうかを確認するためのチェックを短縮する方法はありますか。

if(is_array($groups)){
    /* Check for multiple groups */
    $total = count($groups);
    $hasperm = false;
    while($total > 0){
        /* If account has a bad status dont login */
        switch($group[$total]){
            case 4:
                $errmsg_arr[] = array('type'=>'crucial','alert'=>'Alert!','msg'=>'Your account is not active, contact admin');
                failedAttempt($errmsg_arr);
                break;
            case 6:
                $errmsg_arr[] = array('type'=>'crucial','alert'=>'Alert!','msg'=>'Your account is banned, contact admin');
                failedAttempt($errmsg_arr);
                break;
            case 5:
                $errmsg_arr[] = array('type'=>'crucial','alert'=>'Alert!','msg'=>'Your account is scheduled for deletion, if you are reading this you may still have time to recover your account, Call 716-698-9236. $50 Reactivation fee required.');
                failedAttempt($errmsg_arr);
                break;
        }
        $total--;
    }
}else{
    /* If account has a bad status dont login */
    switch($groups){
        case 4:
            $errmsg_arr[] = array('type'=>'crucial','alert'=>'Alert!','msg'=>'Your account is not active, contact admin');
            failedAttempt($errmsg_arr);
            break;
        case 6:
            $errmsg_arr[] = array('type'=>'crucial','alert'=>'Alert!','msg'=>'Your account is banned, contact admin');
            failedAttempt($errmsg_arr);
            break;
        case 5:
            $errmsg_arr[] = array('type'=>'crucial','alert'=>'Alert!','msg'=>'Your account is scheduled for deletion, if you are reading this you may still have time to recover your account, Call 716-698-9236. $50 Reactivation fee required.');
            failedAttempt($errmsg_arr);
            break;
    }
}
4

1 に答える 1