$mobile_device = false;
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$mobile_agents = array(
'iPhone', // Apple iPhone
'iPod', // Apple iPod touch
'Android', // 1.5+ Android
'Windows Phone', // Windows Phone 7+
'Windows CE', // Windows CE
'Symbian', // Symbian S60
'Opera Mini', // Opera Mini
'BlackBerry', // BlackBerry
'Opera Mobi', // Opera Mobile
'PalmSource' // PalmSource
);
foreach ($mobile_agents as $device) {
if (stristr($user_agent, $device)) {
$mobile_device = true;
break;
}
}
if ($mobile_device) {
return true;
} else {
return false;
}