public static function askBrowser($arrAccepted, $strDefault='de') {
		$res = array('lang' => $strDefault, 'other' => array());
		try {
			$lang_variable = (
				isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])
				? $_SERVER['HTTP_ACCEPT_LANGUAGE']
				: null
			);

			if ( empty($lang_variable) )
				return $res;

			$accepted_languages = preg_split('/,\s*/', $lang_variable);

			$current_lang = $strDefault;
			$current_q = 0;

			$other = array();
			foreach ($accepted_languages as $accepted_language) {
				$res = preg_match('/^([a-z]{1,8}(?:-[a-z]{1,8})*)'.
								   '(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i', $accepted_language, $matches);
				if (!$res)
					continue;

				$lang_code = explode('-', $matches[1]);
				if (isset($matches[2]))
					$lang_quality = (float) $matches[2];
				else
					$lang_quality = 1.0;

				while (count($lang_code)) {
					$full_code = strtolower(join ('-', $lang_code));
					if (in_array($full_code, $arrAccepted)) {
						if ($lang_quality > $current_q) {
							if ($current_lang)
								$other[] = $current_lang;
							$current_lang = $full_code;
							$current_q = $lang_quality;
							break;
						} else
							$other[] = $full_code;
					} else
						$other[] = $full_code;

					array_pop($lang_code);
				}
			}
			return array('lang' => $current_lang, 'other' => $other);;
		} catch (\Exception $e) {
			return $res;
		}
	}
public static function askBrowser($arrAccepted, $strDefault='de') {
		$res = array('lang' => $strDefault, 'other' => array());
		try {
			$lang_variable = (
				isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])
				? $_SERVER['HTTP_ACCEPT_LANGUAGE']
				: null
			);

			if ( empty($lang_variable) )
				return $res;

			$accepted_languages = preg_split('/,\s*/', $lang_variable);

			$current_lang = $strDefault;
			$current_q = 0;

			$other = array();
			foreach ($accepted_languages as $accepted_language) {
				$res = preg_match('/^([a-z]{1,8}(?:-[a-z]{1,8})*)'.
								   '(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i', $accepted_language, $matches);
				if (!$res)
					continue;

				$lang_code = explode('-', $matches[1]);
				if (isset($matches[2]))
					$lang_quality = (float) $matches[2];
				else
					$lang_quality = 1.0;

				while (count($lang_code)) {
					$full_code = strtolower(join ('-', $lang_code));
					if (in_array($full_code, $arrAccepted)) {
						if ($lang_quality > $current_q) {
							if ($current_lang)
								$other[] = $current_lang;
							$current_lang = $full_code;
							$current_q = $lang_quality;
							break;
						} else
							$other[] = $full_code;
					} else
						$other[] = $full_code;

					array_pop($lang_code);
				}
			}
			return array('lang' => $current_lang, 'other' => $other);;
		} catch (\Exception $e) {
			return $res;
		}
	}
public static function askBrowser ( $ arrAccepted , $ strDefault = 'de' ) { $ res = array ( 'lang' => $ strDefault , 'other' => array ( ) ) ; try { $ lang_variable = ( isset ( $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ? $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] : null ) ; if ( empty ( $ lang_variable ) ) return $ res ; $ accepted_languages = preg_split ( '/,\s*/' , $ lang_variable ) ; $ current_lang = $ strDefault ; $ current_q = 0 ; $ other = array ( ) ; foreach ( $ accepted_languages as $ accepted_language ) { $ res = preg_match ( '/^([a-z]{1,8}(?:-[a-z]{1,8})*)' . '(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i' , $ accepted_language , $ matches ) ; if ( ! $ res ) continue ; $ lang_code = explode ( '-' , $ matches [ 1 ] ) ; if ( isset ( $ matches [ 2 ] ) ) $ lang_quality = ( float ) $ matches [ 2 ] ; else $ lang_quality = 1.0 ; while ( count ( $ lang_code ) ) { $ full_code = strtolower ( join ( '-' , $ lang_code ) ) ; if ( in_array ( $ full_code , $ arrAccepted ) ) { if ( $ lang_quality > $ current_q ) { if ( $ current_lang ) $ other [ ] = $ current_lang ; $ current_lang = $ full_code ; $ current_q = $ lang_quality ; break ; } else $ other [ ] = $ full_code ; } else $ other [ ] = $ full_code ; array_pop ( $ lang_code ) ; } } return array ( 'lang' => $ current_lang , 'other' => $ other ) ; ; } catch ( \ Exception $ e ) { return $ res ; } }
Returns the accepted browser language

@param array $arrAccepted
@param string $strDefault
@return array {'lang': PRIMARY LANGUAGE, 'other': ADDITIONAL LANGUAGES}
Returns the accepted browser language