src/Language.php
public function getFromClient() {
		$returner = [];

		// Example string
		// en-ca,en;q=0.8,en-us;q=0.6,de-de;q=0.4,de;q=0.2

		if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
			$parts = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);

			foreach ($parts as $part) {
				preg_match("|^
					(.*?)		# the language part
					([-].*?)?	# the country part (optional)
					(;q=(.*))?	# the quality part (optional)
				$|x", $part, $matches);

				// set quality to 1.0 if not given
				$quality	= isset($matches[4]) ? $matches[4] : '1.0';

				$returner[$quality] = strtolower(trim($matches[1]));
			}
			krsort($returner);
		}
		return $returner;
	}
public function getFromClient() {
		$returner = [];

		// Example string
		// en-ca,en;q=0.8,en-us;q=0.6,de-de;q=0.4,de;q=0.2

		if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
			$parts = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);

			foreach ($parts as $part) {
				preg_match("|^
					(.*?)		# the language part
					([-].*?)?	# the country part (optional)
					(;q=(.*))?	# the quality part (optional)
				$|x", $part, $matches);

				// set quality to 1.0 if not given
				$quality	= isset($matches[4]) ? $matches[4] : '1.0';

				$returner[$quality] = strtolower(trim($matches[1]));
			}
			krsort($returner);
		}
		return $returner;
	}
public function getFromClient ( ) { $ returner = [ ] ; // Example string // en-ca,en;q=0.8,en-us;q=0.6,de-de;q=0.4,de;q=0.2 if ( isset ( $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ) { $ parts = explode ( ',' , $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ; foreach ( $ parts as $ part ) { preg_match ( "|^
					(.*?)		# the language part
					([-].*?)?	# the country part (optional)
					(;q=(.*))?	# the quality part (optional)
				$|x" , $ part , $ matches ) ; // set quality to 1.0 if not given $ quality = isset ( $ matches [ 4 ] ) ? $ matches [ 4 ] : '1.0' ; $ returner [ $ quality ] = strtolower ( trim ( $ matches [ 1 ] ) ) ; } krsort ( $ returner ) ; } return $ returner ; }
Parses the Accept-Language HTTP header sent by the browser.
It will return an array with the languages the user accepts, sorted from most preferred to least preferred.
@return	`array`	Key is the importance, value is the language code.
Parses the Accept - Language HTTP header sent by the browser . It will return an array with the languages the user accepts sorted from most preferred to least preferred .