Style wechseln: ?

Für diese Funktion muß JavaScript aktiviert sein.

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'];
    // 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]));
[arrow up] hoch
letzte Änderung am 23.10.2009
© Christian Eyrich
Hauptseite | Webmaster