php (+/-)
$ua = 'Mozilla/5.0 (Linux; Android 4.2.2; Lenovo A880 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.68 Mobile Safari/537.36';
$type = 'pc';
if(preg_match('#(android|Andr;iphone|ipad|blackberry|bb;|windows phone|WM;|PPC;|IEMobile|Symbian|S60;|j2me)#is', $ua, $match)){
switch (str_replace(';', '', strtolower($match[1]))){
case 'iphone':
case 'ipad':
$type = 'iphone';
break;
case 'android':
case 'andr':
$type = 'android';
break;
case 'blackberry':
case 'bb':
$type = 'blackberry';
break;
case 'windows phone':
case 'wm':
case 'IEMobile':
case 'PPC':
$type = 'wp';
break;
case 'Symbian':
case 'S60':
$type = 'symbian';
break;
case 'j2me':
$type = 'java';
break;
}
}
echo $type;