I have this code bit to get which browser the user uses
$browserArray = array(
'Windows Mobile' => 'IEMobile',
'Android Mobile' => 'Android',
'iPhone Mobile' => 'iPhone',
'Firefox' => 'Firefox',
'Opera' => 'OPR',
'Google Chrome' => 'Chrome',
'Internet Explorer' => 'MSIE',
'Opera' => 'Opera',
'Safari' => 'Safari'
);
foreach ($browserArray as $k => $v) {
if (preg_match("/$v/", $agent)) {
break;
} else {
$k = "Unknown";
}
}
$browser = $k;
But I can't get Opera, it returns Opera as Chrome.
The agent for Opera is "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 OPR/18.0.1284.68"
How can I make it get that Opera is Opera and not Chrome?
OPR/18.0.1284.68
might be Opera's identifier (OPR
) and version number – Bojangles