PHP Language Detection

This is an example of how to detect the browser language and how to take a certain action based on it.

<?
$lang 
getenv ("HTTP_ACCEPT_LANGUAGE");
$set_lang explode(','$lang);
$i 0;
while ( < 
1) {
$code substr("$set_lang[]"02);
if (
$code == 'en') {
    print(
"English");
    }
elseif (
$code == 'zh') {
    print(
"Chinese");
    }
elseif (
$code == 'nl') {
    print(
"Dutch");
    }
else {
    echo 
'another language <br>';
    echo 
$code ;
    }
$i++;
}
?>

[ < PHP Scripts ]


© by Sebastien Bruggeman