I came across a script that parses HTTP_ACCEPT_LANGUAGE: http://www.thefutureoftheweb.com/blog/use-accept-language-header
this script returns an ORDERED array containing the acceptable langs:
Array
(
[it] => 1
[ar] => 0.8
[ja] => 0.6
[cn] => 0.4
[de] => 0.2
)
Now, I want to make an array containing the available languages like that:
$av_lang = array(‘en’,’fr’,’de’,’it’); (unordered array)
Then I want to loop through the first array and get the first key that is in the second array.
For example, it takes ‘en’ from the first array and check if present in the second array, if not, go to the next key ‘ar’ and check it. if none of them, return a default lang like ‘en’.
Finally I want to get one of the available langs in $av_lang.
Thanks.
Try something like this: