language detect for websites
This is a short function used to detect if a browser indicates, that the user knows a particular language.
function test4Language($test_language)
{
// language list available?
$lang_variable = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
if(empty($lang_variable))
{
// No? -> return false
return 0;
}
// pull out the languages
preg_match_all("/(?:([a-z]+)(?:[-a-zA-Z]*;\s*q=[0-9.]+)?,?)/", $lang_variable, $matches);
return(in_array($test_language, $matches[1]));
}