<?php
function orderedLanguages()
{
$languages = split(",", $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
$lang_q = Array();
foreach( $languages as $aLang ) {
$lang_array = split(";q=", trim( $aLang ) );
$lang = trim( $lang_array[0] );
if( !isset( $lang_array[1] ) )
$q = 1;
else
$q = trim($lang_array[1]);
$lang_q["$lang"] = (float)$q;
}
arsort($lang_q);
//extra code for making the languages key indexed
$i = 0;
$lang_index = Array();
foreach($lang_q as $lang => $q) {
// $lang_q[$i] = $lang; //add to the same array the index key/language
$lang_index[$i] = $lang; //add to a new array the index key/language
$i++;
}
//return $lang_index; // uncomment for returning array with keys={0..n-1}, values={most..least preferred}
return $lang_q;
}
?>
von php.net aus den
Kommentaren.
Denke mal das ist sowas, was du suchst oder?