I have a simple script, in which I am trying to pull the browser type out of an agent string. This should be horribly easy but I cant seem to pull it off.

I am using regex, and have tried a dizzying array of different configurations. The only response I am getting from the script is the default case, that being unknown. In using my own user agent string, I know the word Firefox is within the string but cant capture it.

Code:
$agent = $_SERVER["HTTP_USER_AGENT"];

if (isset($agent)){
switch($agent){
    case 1:
    if (preg_match('/(?:MSIE 3)/', $agent)){
        $browser = "MSIE 3";
        
    }break;
    case 2:
    if (preg_match('/(?:MSIE 4)/', $agent)){
        $browser = "MSIE 4";
        
    }break;
    case 3:
    if (preg_match('/(?:MSIE 5)/', $agent)){
        $browser = "MSIE 5";
       
    } break;
    case 4:
    if (preg_match('/(?:MSIE 6)/', $agent)){
        $browser = "MSIE 6";
        
    }break;
    case 5:
    if (preg_match('/(?:MSIE 7)/', $agent)){
        $browser = "MSIE 7";
        
    }break;
    case 6:
    if (preg_match('/?:(MSIE 8)/', $agent)){
        $browser = "MSIE 8";
     
    } break;
    case 7:
    if (preg_match('/(?:Opera)/', $agent)){
        $browser = "Opera";
        
    }break;
    case 8:
    if (preg_match('/(?:Chrome)/', $agent)){
        $browser = "Chrome";
        
    }break;
    case 9:
    if (preg_match('/(?:Safari)/', $agent)){
        $browser = "Safari";
        
    }break;
    case 10:
    if (preg_match('/^(?:(Firefox))$/', $agent)){
        $browser = "Firefox";        
    }break;
          
    default:
    $browser = "Unknown"; 
}
}
I have tried the break within the if statement and outside. The script from here just goes on to enter the browser into the database.

Any thoughts?