Browser language problem
| From: | John M | Date: | Wed, 22 Jan 2003 20:54:00 +0000 |
| Subject: | Browser language problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-132678@lists.php.net to get a copy of this message | ||
Hello,
I have the code below, but it doesn't work. I see the message "It is an
array" but nothing else. What can be the problem?
How can I get the actual browser language?
I use WinXp Prof, Apache 2.0.43, PHP 4.2.3, safe_mode is on.
Thanks!
<?php
global $HTTP_ACCEPT_LANGUAGE;
$arr_lang = preg_split('/(\s*,\s*)/', $HTTP_ACCEPT_LANGUAGE);
if (is_array($arr_lang)) {
echo "It is an array";
$lang_first = strtolower((trim(strval($arr_lang[0]))));
echo $lang_first;
$lang_first = substr($lang_first, 0, 2);
$lang = $lang_first;
echo $lang;
}
?>