My Useragent, when tested from Opera browser, reads:
Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.125 Safari/537.36 OPR/30.0.1835.88
Now, I had the following script to test Browser:
$browser_list = array(
array('search_string' => 'chrome', 'bname' => 'Google Chrome', 'matchname' => 'chrome', 'ub' => 'Chrome'),
array('search_string' => 'firefox', 'bname' => 'Mozilla Firefox', 'matchname' => 'firefox', 'ub' => 'Firefox'),
array('search_string' => 'safari', 'bname' => 'Apple Safari', 'matchname' => 'Safari', 'ub' => 'Safari'),
array('search_string' => 'netscape', 'bname' => 'Netscape', 'matchname' => 'Netscape', 'ub' => 'Netscape'),
array('search_string' => 'opera', 'bname' => 'Opera', 'matchname' => 'Opera', 'ub' => 'Opera'), // Must be before IE
array('search_string' => 'MSIE', 'bname' => 'Internet Explorer', 'matchname' => 'IE', 'ub' => 'MSIE'),
array('search_string' => 'Mozilla', 'bname' => 'Internet Explorer', 'matchname' => 'IE', 'ub' => 'MSIE'), // Hack for IE 11 as the LAST one so you know not match the above
);
// Next get the name of the useragent yes seperately and for good reason
foreach ($browser_list as $item) {
echo $item['search_string'];
if (stripos($userAgent, $item['search_string']) !== false) {
$bname = $item['bname'];
$matchname = $item['matchname'];
$ub = $item['ub'];
echo "breaking";
break;
}
}
But, since the UserAgent contains all the browsername, I am facing the problem.
Also, why the usergent from Opera is such weird?