经测试代码如下:
<?PHP
function get_client_language($availableLanguages,$default='en'){
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$langs=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach ($langs as $value){
$choice=substr($value,2);
if(in_array($choice,$availableLanguages)){
return $choice;
}
}
}
return $default;
}
/*** 以上代码来自:编程之家 jb51.cc(jb51.cc) ***/
?>