daily pastebin goal
64%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getBrowser()
  2. {
  3.  
  4.     global $user_agent;
  5.  
  6.     $browser = "Unknown Browser";
  7.  
  8.     $browser_array = array(
  9.         '/msie/i' => 'Internet Explorer',
  10.         '/firefox/i' => 'Firefox',
  11.         '/safari/i' => 'Safari',
  12.         '/chrome/i' => 'Chrome',
  13.         '/opera/i' => 'Opera',
  14.         '/netscape/i' => 'Netscape',
  15.         '/maxthon/i' => 'Maxthon',
  16.         '/konqueror/i' => 'Konqueror',
  17.         '/mobile/i' => 'Handheld Browser'
  18.     );
  19.  
  20.     foreach ($browser_array as $regex => $value) {
  21.  
  22.         if (preg_match($regex, $user_agent)) {
  23.             $browser = $value;
  24.         }
  25.  
  26.     }
  27.  
  28.     return $browser;
  29.  
  30. }
RAW Paste Data
Top