Answers
OmniPotens 2013-08-06T01:02:56
If you want to get all those information, you might want to read this:\nhttp://php.net/manual/en/function.get-browser.php\n\nYou can run the sample code and you'll see how it works:\n\n<?php\necho $_SERVER['HTTP_USER_AGENT'] . \"\\n\\n\";\n\n$browser = get_browser(null, true);\nprint_r($browser);\n?>\n\n\nThe above example will output something similar to:\n\nMozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3\n\nArray\n(\n [browser_name_regex] => ^mozilla/5\\.0 (windows; .; windows nt 5\\.1; .*rv:.*) gecko/.* firefox/0\\.9.*$\n [browser_name_pattern] => Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9*\n [parent] => Firefox 0.9\n [platform] => WinXP\n [browser] => Firefox\n [version] => 0.9\n [majorver] => 0\n [minorver] => 9\n [cssversion] => 2\n [frames] => 1\n [iframes] => 1\n [tables] => 1\n [cookies] => 1\n [backgroundsounds] =>\n [vbscript] =>\n [javascript] => 1\n [javaapplets] => 1\n [activexcontrols] =>\n [cdf] =>\n [aol] =>\n [beta] => 1\n [win16] =>\n [crawler] =>\n [stripper] =>\n [wap] =>\n [netclr] =>\n)\n",
antoni 2016-06-20T01:20:21
If you want very few info like a class in your html for common browsers for instance, you could use:\n\nfunction get_browser()\n{\n $browser = '';\n $ua = strtolower($_SERVER['HTTP_USER_AGENT']);\n if (preg_match('~(?:msie ?|trident.+?; ?rv: ?)(\\d+)~', $ua, $matches)) $browser = 'ie ie'.$matches[1];\n elseif (preg_match('~(safari|chrome|firefox)~', $ua, $matches)) $browser = $matches[1];\n\n return $browser;\n}\n\n\nwhich will return 'safari' or 'firefox' or 'chrome', or 'ie ie8', 'ie ie9', 'ie ie10', 'ie ie11'.",
anon 2013-08-06T00:57:10
You can look for this information in $_SERVER['HTTP_USER_AGENT'], but its format is free-form, not guaranteed to be sent, and could easily be altered by the user, whether for privacy or other reasons.\n\nIf you've not set the browsecap directive, this will return a warning. To make sure it's set, you can retrieve the value using ini_get and see if it's set.\n\nif(ini_get(\"browscap\")) {\n $browser = get_browser(null, true);\n $browser = get_browser($_SERVER['HTTP_USER_AGENT']); \n} \n\n\nAs kba explained in his answer, your browser sends a lot of information to the server while loading a webpage. Most websites use these User-agent information to determine the visitor's operating system, browser and various information.",
Funk Forty Niner 2013-08-06T01:29:56
The code below could explain in its own right, how http://thismachine.info/ is able to show which operating system someone is using.\nWhat it does is that, it sniffs your core operating system model, for example windows nt 5.1 as my own.\nIt then passes windows nt 5.1/i to Windows XP as the operating system.\nUsing: '/windows nt 5.1/i' => 'Windows XP', from an array.\nYou could say guesswork, or an approximation yet nonetheless pretty much bang on.\nBorrowed from an answer on SO https://stackoverflow.com/a/15497878/\n<?php\n\n$user_agent = $_SERVER['HTTP_USER_AGENT'];\n\nfunction getOS() { \n\n global $user_agent;\n\n $os_platform = "Unknown OS Platform";\n\n $os_array = array(\n '/windows nt 10/i' => 'Windows 10',\n '/windows nt 6.3/i' => 'Windows 8.1',\n '/windows nt 6.2/i' => 'Windows 8',\n '/windows nt 6.1/i' => 'Windows 7',\n '/windows nt 6.0/i' => 'Windows Vista',\n '/windows nt 5.2/i' => 'Windows Server 2003/XP x64',\n '/windows nt 5.1/i' => 'Windows XP',\n '/windows xp/i' => 'Windows XP',\n '/windows nt 5.0/i' => 'Windows 2000',\n '/windows me/i' => 'Windows ME',\n '/win98/i' => 'Windows 98',\n '/win95/i' => 'Windows 95',\n '/win16/i' => 'Windows 3.11',\n '/macintosh|mac os x/i' => 'Mac OS X',\n '/mac_powerpc/i' => 'Mac OS 9',\n '/linux/i' => 'Linux',\n '/ubuntu/i' => 'Ubuntu',\n '/iphone/i' => 'iPhone',\n '/ipod/i' => 'iPod',\n '/ipad/i' => 'iPad',\n '/android/i' => 'Android',\n '/blackberry/i' => 'BlackBerry',\n '/webos/i' => 'Mobile'\n );\n\n foreach ($os_array as $regex => $value)\n if (preg_match($regex, $user_agent))\n $os_platform = $value;\n\n return $os_platform;\n}\n\nfunction getBrowser() {\n\n global $user_agent;\n\n $browser = "Unknown Browser";\n\n $browser_array = array(\n '/msie/i' => 'Internet Explorer',\n '/firefox/i' => 'Firefox',\n '/safari/i' => 'Safari',\n '/chrome/i' => 'Chrome',\n '/edge/i' => 'Edge',\n '/opera/i' => 'Opera',\n '/netscape/i' => 'Netscape',\n '/maxthon/i' => 'Maxthon',\n '/konqueror/i' => 'Konqueror',\n '/mobile/i' => 'Handheld Browser'\n );\n\n foreach ($browser_array as $regex => $value)\n if (preg_match($regex, $user_agent))\n $browser = $value;\n\n return $browser;\n}\n\n\n$user_os = getOS();\n$user_browser = getBrowser();\n\n$device_details = "<strong>Browser: </strong>".$user_browser."<br /><strong>Operating System: </strong>".$user_os."";\n\nprint_r($device_details);\n\necho("<br /><br /><br />".$_SERVER['HTTP_USER_AGENT']."");\n\n?>\n\n\nFootnotes:\n(Jan. 19/14) There was a suggested edit on Jan. 18, 2014 to add /msie|trident/i by YJSoft a new member on SO.\nThe comment read as:\nComment: because msie11's ua doesn't include msie (it includes trident instead)\nI researched this for a bit, and found a few links explaining the Trident string.\n\nhttp://www.sitepoint.com/ie11-smells-like-firefox/\nhttp://www.upsdell.ca/BrowserNews/res_sniff.htm\nHow can I target only Internet Explorer 11 with JavaScript?\nhttp://en.wikipedia.org/wiki/Trident_%28layout_engine%29\nhttps://stackoverflow.com/a/17907562/1415724\nhttp://msdn.microsoft.com/en-us/library/ie/bg182625(v=vs.110).aspx\nAn article on MSDN Blogs\nAn article on NCZOnline\n\nAlthough the edit was rejected (not by myself, but by some of the other editors), it's worth reading up on the links above, and to use your proper judgement.\n\nAs per a question asked about detecting SUSE, have found this piece of code at the following URL:\n\nhttp://codes-sources.commentcamarche.net/source/49533-operating-system-detection\n\nAdditional code:\n/* return Operating System */\nfunction operating_system_detection(){\n if ( isset( $_SERVER ) ) {\n $agent = $_SERVER['HTTP_USER_AGENT'];\n }\n else {\n global $HTTP_SERVER_VARS;\n if ( isset( $HTTP_SERVER_VARS ) ) {\n $agent = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];\n }\n else {\n global $HTTP_USER_AGENT;\n $agent = $HTTP_USER_AGENT;\n }\n }\n $ros[] = array('Windows XP', 'Windows XP');\n $ros[] = array('Windows NT 5.1|Windows NT5.1)', 'Windows XP');\n $ros[] = array('Windows 2000', 'Windows 2000');\n $ros[] = array('Windows NT 5.0', 'Windows 2000');\n $ros[] = array('Windows NT 4.0|WinNT4.0', 'Windows NT');\n $ros[] = array('Windows NT 5.2', 'Windows Server 2003');\n $ros[] = array('Windows NT 6.0', 'Windows Vista');\n $ros[] = array('Windows NT 7.0', 'Windows 7');\n $ros[] = array('Windows CE', 'Windows CE');\n $ros[] = array('(media center pc).([0-9]{1,2}\\.[0-9]{1,2})', 'Windows Media Center');\n $ros[] = array('(win)([0-9]{1,2}\\.[0-9x]{1,2})', 'Windows');\n $ros[] = array('(win)([0-9]{2})', 'Windows');\n $ros[] = array('(windows)([0-9x]{2})', 'Windows');\n // Doesn't seem like these are necessary...not totally sure though..\n //$ros[] = array('(winnt)([0-9]{1,2}\\.[0-9]{1,2}){0,1}', 'Windows NT');\n //$ros[] = array('(windows nt)(([0-9]{1,2}\\.[0-9]{1,2}){0,1})', 'Windows NT'); // fix by bg\n $ros[] = array('Windows ME', 'Windows ME');\n $ros[] = array('Win 9x 4.90', 'Windows ME');\n $ros[] = array('Windows 98|Win98', 'Windows 98');\n $ros[] = array('Windows 95', 'Windows 95');\n $ros[] = array('(windows)([0-9]{1,2}\\.[0-9]{1,2})', 'Windows');\n $ros[] = array('win32', 'Windows');\n $ros[] = array('(java)([0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,2})', 'Java');\n $ros[] = array('(Solaris)([0-9]{1,2}\\.[0-9x]{1,2}){0,1}', 'Solaris');\n $ros[] = array('dos x86', 'DOS');\n $ros[] = array('unix', 'Unix');\n $ros[] = array('Mac OS X', 'Mac OS X');\n $ros[] = array('Mac_PowerPC', 'Macintosh PowerPC');\n $ros[] = array('(mac|Macintosh)', 'Mac OS');\n $ros[] = array('(sunos)([0-9]{1,2}\\.[0-9]{1,2}){0,1}', 'SunOS');\n $ros[] = array('(beos)([0-9]{1,2}\\.[0-9]{1,2}){0,1}', 'BeOS');\n $ros[] = array('(risc os)([0-9]{1,2}\\.[0-9]{1,2})', 'RISC OS');\n $ros[] = array('os/2', 'OS/2');\n $ros[] = array('freebsd', 'FreeBSD');\n $ros[] = array('openbsd', 'OpenBSD');\n $ros[] = array('netbsd', 'NetBSD');\n $ros[] = array('irix', 'IRIX');\n $ros[] = array('plan9', 'Plan9');\n $ros[] = array('osf', 'OSF');\n $ros[] = array('aix', 'AIX');\n $ros[] = array('GNU Hurd', 'GNU Hurd');\n $ros[] = array('(fedora)', 'Linux - Fedora');\n $ros[] = array('(kubuntu)', 'Linux - Kubuntu');\n $ros[] = array('(ubuntu)', 'Linux - Ubuntu');\n $ros[] = array('(debian)', 'Linux - Debian');\n $ros[] = array('(CentOS)', 'Linux - CentOS');\n $ros[] = array('(Mandriva).([0-9]{1,3}(\\.[0-9]{1,3})?(\\.[0-9]{1,3})?)', 'Linux - Mandriva');\n $ros[] = array('(SUSE).([0-9]{1,3}(\\.[0-9]{1,3})?(\\.[0-9]{1,3})?)', 'Linux - SUSE');\n $ros[] = array('(Dropline)', 'Linux - Slackware (Dropline GNOME)');\n $ros[] = array('(ASPLinux)', 'Linux - ASPLinux');\n $ros[] = array('(Red Hat)', 'Linux - Red Hat');\n // Loads of Linux machines will be detected as unix.\n // Actually, all of the linux machines I've checked have the 'X11' in the User Agent.\n //$ros[] = array('X11', 'Unix');\n $ros[] = array('(linux)', 'Linux');\n $ros[] = array('(amigaos)([0-9]{1,2}\\.[0-9]{1,2})', 'AmigaOS');\n $ros[] = array('amiga-aweb', 'AmigaOS');\n $ros[] = array('amiga', 'Amiga');\n $ros[] = array('AvantGo', 'PalmOS');\n //$ros[] = array('(Linux)([0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,3}(rel\\.[0-9]{1,2}){0,1}-([0-9]{1,2}) i([0-9]{1})86){1}', 'Linux');\n //$ros[] = array('(Linux)([0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,3}(rel\\.[0-9]{1,2}){0,1} i([0-9]{1}86)){1}', 'Linux');\n //$ros[] = array('(Linux)([0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,3}(rel\\.[0-9]{1,2}){0,1})', 'Linux');\n $ros[] = array('[0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,3}', 'Linux');\n $ros[] = array('(webtv)/([0-9]{1,2}\\.[0-9]{1,2})', 'WebTV');\n $ros[] = array('Dreamcast', 'Dreamcast OS');\n $ros[] = array('GetRight', 'Windows');\n $ros[] = array('go!zilla', 'Windows');\n $ros[] = array('gozilla', 'Windows');\n $ros[] = array('gulliver', 'Windows');\n $ros[] = array('ia archiver', 'Windows');\n $ros[] = array('NetPositive', 'Windows');\n $ros[] = array('mass downloader', 'Windows');\n $ros[] = array('microsoft', 'Windows');\n $ros[] = array('offline explorer', 'Windows');\n $ros[] = array('teleport', 'Windows');\n $ros[] = array('web downloader', 'Windows');\n $ros[] = array('webcapture', 'Windows');\n $ros[] = array('webcollage', 'Windows');\n $ros[] = array('webcopier', 'Windows');\n $ros[] = array('webstripper', 'Windows');\n $ros[] = array('webzip', 'Windows');\n $ros[] = array('wget', 'Windows');\n $ros[] = array('Java', 'Unknown');\n $ros[] = array('flashget', 'Windows');\n // delete next line if the script show not the right OS\n //$ros[] = array('(PHP)/([0-9]{1,2}.[0-9]{1,2})', 'PHP');\n $ros[] = array('MS FrontPage', 'Windows');\n $ros[] = array('(msproxy)/([0-9]{1,2}.[0-9]{1,2})', 'Windows');\n $ros[] = array('(msie)([0-9]{1,2}.[0-9]{1,2})', 'Windows');\n $ros[] = array('libwww-perl', 'Unix');\n $ros[] = array('UP.Browser', 'Windows CE');\n $ros[] = array('NetAnts', 'Windows');\n $file = count ( $ros );\n $os = '';\n for ( $n=0 ; $n<$file ; $n++ ){\n if ( preg_match('/'.$ros[$n][0].'/i' , $agent, $name)){\n $os = @$ros[$n][1].' '.@$name[2];\n break;\n }\n }\n return trim ( $os );\n}\n\n\nEdit: April 12, 2015\nI noticed a question yesterday that could be relevant to this Q&A and may be helpful for some. In regards to:\nMozilla/5.0 (Linux; Android 4.4.2; SAMSUNG-GT-I9505 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36\n\nQuestion: Store specific data in variable from another variable with regex with PHP\nAnswer: https://stackoverflow.com/a/29584014/\n\n\nAnother edit, and adding a reference link that was asked (and answered/accepted today, Nov. 4/16) which may be of use.\nConsult the Q&A here on Stack:\n\nPHP Regex for OS detection\n",
kba 2013-08-06T00:56:20
When you go to a website, your browser sends a request to the web server including a lot of information. This information might look something like this:\n\nGET /questions/18070154/get-operating-system-info-with-php HTTP/1.1 \nHost: stackoverflow.com \nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 \n (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36 \nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 \nAccept-Language: en-us,en;q=0.5 \nAccept-Encoding: gzip,deflate,sdch \nAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 \nKeep-Alive: 300 \nConnection: keep-alive \nCookie: <cookie data removed> \nPragma: no-cache \nCache-Control: no-cache\n\n\nThese information are all used by the web server to determine how to handle the request; the preferred language and whether compression is allowed.\n\nIn PHP, all this information is stored in the $_SERVER array. To see what you're sending to a web server, create a new PHP file and print out everything from the array.\n\n\n<pre><?php print_r($_SERVER); ?></pre>\n\n\nThis will give you a nice representation of everything that's being sent to the server, from where you can extract the desired information, e.g. $_SERVER['HTTP_USER_AGENT'] to get the operating system and browser.",
vee 2013-08-06T01:00:20
Took the following code from php manual for get_browser. \n\n$browser = get_browser(null, true);\nprint_r($browser);\n\n\nThe $browser array has platform information included which gives you the specific Operating System in use. \n\nPlease make sure to see the \"Notes\" section in that page. This might be something (thismachine.info) is using if not something already pointed in other answers.",
Timo Huovinen 2017-09-07T08:45:25
Based on the answer by Fred-II I wanted to share my take on the getOS function, it avoids globals, merges both lists and detects the architecture (x32/x64)\n/**\n * @param $user_agent null\n * @return string\n */\nfunction getOS($user_agent = null)\n{\n if(!isset($user_agent) && isset($_SERVER['HTTP_USER_AGENT'])) {\n $user_agent = $_SERVER['HTTP_USER_AGENT'];\n }\n\n // https://stackoverflow.com/questions/18070154/get-operating-system-info-with-php\n $os_array = [\n 'windows nt 10' => 'Windows 10',\n 'windows nt 6.3' => 'Windows 8.1',\n 'windows nt 6.2' => 'Windows 8',\n 'windows nt 6.1|windows nt 7.0' => 'Windows 7',\n 'windows nt 6.0' => 'Windows Vista',\n 'windows nt 5.2' => 'Windows Server 2003/XP x64',\n 'windows nt 5.1' => 'Windows XP',\n 'windows xp' => 'Windows XP',\n 'windows nt 5.0|windows nt5.1|windows 2000' => 'Windows 2000',\n 'windows me' => 'Windows ME',\n 'windows nt 4.0|winnt4.0' => 'Windows NT',\n 'windows ce' => 'Windows CE',\n 'windows 98|win98' => 'Windows 98',\n 'windows 95|win95' => 'Windows 95',\n 'win16' => 'Windows 3.11',\n 'mac os x 10.1[^0-9]' => 'Mac OS X Puma',\n 'macintosh|mac os x' => 'Mac OS X',\n 'mac_powerpc' => 'Mac OS 9',\n 'ubuntu' => 'Linux - Ubuntu',\n 'iphone' => 'iPhone',\n 'ipod' => 'iPod',\n 'ipad' => 'iPad',\n 'android' => 'Android',\n 'blackberry' => 'BlackBerry',\n 'webos' => 'Mobile',\n 'linux' => 'Linux',\n\n '(media center pc).([0-9]{1,2}\\.[0-9]{1,2})'=>'Windows Media Center',\n '(win)([0-9]{1,2}\\.[0-9x]{1,2})'=>'Windows',\n '(win)([0-9]{2})'=>'Windows',\n '(windows)([0-9x]{2})'=>'Windows',\n\n // Doesn't seem like these are necessary...not totally sure though..\n //'(winnt)([0-9]{1,2}\\.[0-9]{1,2}){0,1}'=>'Windows NT',\n //'(windows nt)(([0-9]{1,2}\\.[0-9]{1,2}){0,1})'=>'Windows NT', // fix by bg\n\n 'Win 9x 4.90'=>'Windows ME',\n '(windows)([0-9]{1,2}\\.[0-9]{1,2})'=>'Windows',\n 'win32'=>'Windows',\n '(java)([0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,2})'=>'Java',\n '(Solaris)([0-9]{1,2}\\.[0-9x]{1,2}){0,1}'=>'Solaris',\n 'dos x86'=>'DOS',\n 'Mac OS X'=>'Mac OS X',\n 'Mac_PowerPC'=>'Macintosh PowerPC',\n '(mac|Macintosh)'=>'Mac OS',\n '(sunos)([0-9]{1,2}\\.[0-9]{1,2}){0,1}'=>'SunOS',\n '(beos)([0-9]{1,2}\\.[0-9]{1,2}){0,1}'=>'BeOS',\n '(risc os)([0-9]{1,2}\\.[0-9]{1,2})'=>'RISC OS',\n 'unix'=>'Unix',\n 'os/2'=>'OS/2',\n 'freebsd'=>'FreeBSD',\n 'openbsd'=>'OpenBSD',\n 'netbsd'=>'NetBSD',\n 'irix'=>'IRIX',\n 'plan9'=>'Plan9',\n 'osf'=>'OSF',\n 'aix'=>'AIX',\n 'GNU Hurd'=>'GNU Hurd',\n '(fedora)'=>'Linux - Fedora',\n '(kubuntu)'=>'Linux - Kubuntu',\n '(ubuntu)'=>'Linux - Ubuntu',\n '(debian)'=>'Linux - Debian',\n '(CentOS)'=>'Linux - CentOS',\n '(Mandriva).([0-9]{1,3}(\\.[0-9]{1,3})?(\\.[0-9]{1,3})?)'=>'Linux - Mandriva',\n '(SUSE).([0-9]{1,3}(\\.[0-9]{1,3})?(\\.[0-9]{1,3})?)'=>'Linux - SUSE',\n '(Dropline)'=>'Linux - Slackware (Dropline GNOME)',\n '(ASPLinux)'=>'Linux - ASPLinux',\n '(Red Hat)'=>'Linux - Red Hat',\n // Loads of Linux machines will be detected as unix.\n // Actually, all of the linux machines I've checked have the 'X11' in the User Agent.\n //'X11'=>'Unix',\n '(linux)'=>'Linux',\n '(amigaos)([0-9]{1,2}\\.[0-9]{1,2})'=>'AmigaOS',\n 'amiga-aweb'=>'AmigaOS',\n 'amiga'=>'Amiga',\n 'AvantGo'=>'PalmOS',\n //'(Linux)([0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,3}(rel\\.[0-9]{1,2}){0,1}-([0-9]{1,2}) i([0-9]{1})86){1}'=>'Linux',\n //'(Linux)([0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,3}(rel\\.[0-9]{1,2}){0,1} i([0-9]{1}86)){1}'=>'Linux',\n //'(Linux)([0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,3}(rel\\.[0-9]{1,2}){0,1})'=>'Linux',\n '[0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,3}'=>'Linux',\n '(webtv)/([0-9]{1,2}\\.[0-9]{1,2})'=>'WebTV',\n 'Dreamcast'=>'Dreamcast OS',\n 'GetRight'=>'Windows',\n 'go!zilla'=>'Windows',\n 'gozilla'=>'Windows',\n 'gulliver'=>'Windows',\n 'ia archiver'=>'Windows',\n 'NetPositive'=>'Windows',\n 'mass downloader'=>'Windows',\n 'microsoft'=>'Windows',\n 'offline explorer'=>'Windows',\n 'teleport'=>'Windows',\n 'web downloader'=>'Windows',\n 'webcapture'=>'Windows',\n 'webcollage'=>'Windows',\n 'webcopier'=>'Windows',\n 'webstripper'=>'Windows',\n 'webzip'=>'Windows',\n 'wget'=>'Windows',\n 'Java'=>'Unknown',\n 'flashget'=>'Windows',\n\n // delete next line if the script show not the right OS\n //'(PHP)/([0-9]{1,2}.[0-9]{1,2})'=>'PHP',\n 'MS FrontPage'=>'Windows',\n '(msproxy)/([0-9]{1,2}.[0-9]{1,2})'=>'Windows',\n '(msie)([0-9]{1,2}.[0-9]{1,2})'=>'Windows',\n 'libwww-perl'=>'Unix',\n 'UP.Browser'=>'Windows CE',\n 'NetAnts'=>'Windows',\n ];\n\n // https://github.com/ahmad-sa3d/php-useragent/blob/master/core/user_agent.php\n $arch_regex = '/\\b(x86_64|x86-64|Win64|WOW64|x64|ia64|amd64|ppc64|sparc64|IRIX64)\\b/ix';\n $arch = preg_match($arch_regex, $user_agent) ? '64' : '32';\n\n foreach ($os_array as $regex => $value) {\n if (preg_match('{\\b('.$regex.')\\b}i', $user_agent)) {\n return $value.' x'.$arch;\n }\n }\n\n return 'Unknown';\n}\n",