Código PHP:
function _get_browser()
{
$browser = array ( //reversed array
"OPERA",
"MSIE", // parent
"NETSCAPE",
"FIREFOX",
"SAFARI",
"KONQUEROR",
"MOZILLA" // parent
);
$info[browser] = "OTHER";
foreach ($browser as $parent)
{
if ( ($s = strpos(strtoupper($_SERVER['HTTP_USER_AGENT']), $parent)) !== FALSE )
{
$f = $s + strlen($parent);
$version = substr($_SERVER['HTTP_USER_AGENT'], $f, 5);
$version = preg_replace('/[^0-9,.]/','',$version);
$info[browser] = $parent;
$info[version] = $version;
break; // first match wins
}
}
return $info;
}