note 27862 deleted from function.get-browser by aidan

From: Date: Sun, 03 Oct 2004 03:54:19 +0000
Subject: note 27862 deleted from function.get-browser by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77773@lists.php.net to get a copy of this message
Note Submitter: bart at friesoft dot nl ---- Another way, not depending on the actual browser version is this one (it parses the $HTTP_USER_AGENT string): preg_match_all("/[\w\.]+\/[\w\.]+/", $HTTP_USER_AGENT, $browser); preg_match_all("/\(.*\)/", $HTTP_USER_AGENT, $features); $browser = $browser[0]; foreach ($browser as $key=>$value) { $brow_ver = explode("/", $value); $browser[$brow_ver[0]] = $brow_ver[1]; unset($browser[$key]); } $features = $features[0][0]; $features = substr($features, 1, -1); $features = explode("; ", $features); At the end you have two arrays: $browser, which is an associative array that holds the browser types and version (mozilla for example has Mozilla => 5.0 and Gecko => 20020304) and $features that holds the features of the browser (use rv:<moz-version> to see the build of Mozilla).

« previous php.notes (#77773) next »