Mendeteksi platform seluler di PHP

<?php


function detect_platform() {
	if (preg_match('/iphone|ipad|ipod/i', $_SERVER['HTTP_USER_AGENT'])) {
		if (!preg_match('/safari\/[0-9]+/i', $_SERVER['HTTP_USER_AGENT'])) {
			return 'ios-share';
		} else {
			return 'ios';
		}
	} else if (stripos($_SERVER['HTTP_USER_AGENT'], 'android')!==false) {
		return 'android';
	} else {
		return 'default';
	}
}
Amin Arjmand