Detect Browser
function detectBrowser ($check){
$ua = $_SERVER["HTTP_USER_AGENT"];
/* ==== Detect the OS ==== */
// ---- Mobile ----
// Android
$arrayToCheck['android'] = strpos($ua, 'Android') ? true : false;
// BlackBerry
$arrayToCheck['blackberry'] = strpos($ua, 'BlackBerry') ? true : false;
// iPhone
$arrayToCheck['iphone'] = strpos($ua, 'iPhone') ? true : false;
// iPad
$arrayToCheck['ipad'] = strpos($ua, 'iPad') ? true : false;
// Palm
$arrayToCheck['palm'] = strpos($ua, 'Palm') ? true : false;
// WindowsPhone
$arrayToCheck['winPhone'] = strpos(strtolower($ua), 'windows phone os') ? true : false;
// ---- Desktop ----
// Linux
$arrayToCheck['linux'] = strpos($ua, 'Linux') ? true : false;
// Macintosh
$arrayToCheck['mac'] = strpos($ua, 'Macintosh') ? true : false;
// Windows
$arrayToCheck['win'] = strpos($ua, 'Windows') ? true : false;
/* ============================ */
/* ==== Detect the UA ==== */
// Chrome
$arrayToCheck['chrome'] = strpos($ua, 'Chrome') ? true : false; // Google Chrome
// Firefox
$arrayToCheck['firefox'] = strpos($ua, 'Firefox') ? true : false; // All Firefox
$arrayToCheck['firefox_2'] = strpos($ua, 'Firefox/2.0') ? true : false; // Firefox 2
$arrayToCheck['firefox_3'] = strpos($ua, 'Firefox/3.0') ? true : false; // Firefox 3
$arrayToCheck['firefox_3_6'] = strpos($ua, 'Firefox/3.6') ? true : false; // Firefox 3.6
// Internet Exlporer
$arrayToCheck['msie'] = strpos($ua, 'MSIE') ? true : false; // All Internet Explorer
$arrayToCheck['msie_7'] = strpos($ua, 'MSIE 7.0') ? true : false; // Internet Explorer 7
$arrayToCheck['msie_8'] = strpos($ua, 'MSIE 8.0') ? true : false; // Internet Explorer 8
$arrayToCheck['msie_9'] = strpos($ua, 'MSIE 9.0') ? true : false; // Internet Explorer 9
$arrayToCheck['msie_10'] = strpos($ua, 'MSIE 10.0') ? true : false; // Internet Explorer 10
$arrayToCheck['msie_11'] = strpos($ua, 'MSIE 10.0') ? true : false; // Internet Explorer 11
// Opera
$arrayToCheck['opera'] = preg_match("/\bOpera\b/i", $ua); // All Opera
// Safari
$arrayToCheck['safari'] = strpos($ua, 'Safari') ? true : false; // All Safari
$arrayToCheck['safari_2'] = strpos($ua, 'Safari/419') ? true : false; // Safari 2
$arrayToCheck['safari_3'] = strpos($ua, 'Safari/525') ? true : false; // Safari 3
$arrayToCheck['safari_3_1'] = strpos($ua, 'Safari/528') ? true : false; // Safari 3.1
$arrayToCheck['safari_4'] = strpos($ua, 'Safari/531') ? true : false; // Safari 4
}