i have this function, and i get this error Deprecated: Function eregi() is deprecated in...
. If i change eregi
to preg_match
i get this error Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in...
function getBrowser($userAgent) {
$browsers = array(
'Opera' => 'Opera',
'Mozilla Firefox'=> '(Firebird)|(Firefox)', // Use regular expressions as value to identify browser
'Galeon' => 'Galeon',
'Chrome'=>'Gecko',
'MyIE'=>'MyIE',
'Lynx' => 'Lynx',
'Netscape' => '(Mozilla/4\.75)|(Netscape6)|(Mozilla/4\.08)|(Mozilla/4\.5)|(Mozilla/4\.6)|(Mozilla/4\.79)',
'Konqueror'=>'Konqueror',
'SearchBot' => '(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)',
'Internet Explorer 8' => '(MSIE 8\.[0-9]+)',
'Internet Explorer 7' => '(MSIE 7\.[0-9]+)',
'Internet Explorer 6' => '(MSIE 6\.[0-9]+)',
'Internet Explorer 5' => '(MSIE 5\.[0-9]+)',
'Internet Explorer 4' => '(MSIE 4\.[0-9]+)',
);
foreach($browsers as $browser=>$pattern) {
if(eregi($pattern, $userAgent)) {
return $browser;
}
}
return 'Unknown';
}
any ideas on how to fix this. and also i would like a dumbed down explanation on what is happening if you guys dont mind so i can understand
thanks