Aug.19

Detecting Android, iPhone, iPod, iPad and BlackBerry browser with PHP

$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
$ua_checker = array(
  'android'=>preg_match('/android/', $ua),
  'iphone'=>preg_match('/iphone|ipod|ipad/', $ua),
  'blackberry'=>preg_match('/blackberry/', $ua)
);
if ($ua_checker['android']) {
  // up to you
}
else if ($ua_checker['iphone']) {
  // up to you
}
else if ($ua_checker['blackberry']) {
  // up to you
}
Web Programming

Aug.19

Detecting Android, iPhone, iPod, iPad and BlackBerry browser with JavaScript

var ua = navigator.userAgent.toLowerCase();
var ua_checker = {
  android: ua.match(/android/),
  iphone: ua.match(/(iphone|ipod|ipad)/),
  blackberry: ua.match(/blackberry/)
};
if (ua_checker.android) {
  // up to you
}
else if (ua_checker.iphone) {
  // up to you
}
else if (ua_checker.blackberry) {
  // up to you
}
Web Programming