<?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; } ?> While you can't reference the key by number, You can use foreach to pull elements. This will be in order. So getting the key with array_keys should work in the preferred order too. I've added a few extra lines of commented code for reordering the array into one(s) that reference the language by number (if you need it) :D skrollster 27-Mar-2005 12:36 $_SERVER["REMOTE_USER"] and $_SERVER['PHP_AUTH_USER'] is the same variable i think.. anonymous 04-Mar-2005 06:12 I don't see the $_SERVER["REMOTE_USER"] listed in this document. This displays the username used to login using .htaccess. 28-Feb-2005 10:41 Matt Johnson says that one should never urldecode() $_GET data. This is incorrect. If magic_quotes_gpc is turned off in php.ini, then you *do* need to urldecode() $_GET data. Having magic_quotes_gpc turned off is considered good practise. 17-Feb-2005 07:30 grlprgrmmr wrote: you can use these to reconstructed the current page url. <?php echo 'http'; if($_SERVER['HTTPS']=='on'){echo 's';} echo '://'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME']; if($_SERVER['QUERY_STRING']>' '){echo '?'.$_SERVER['QUERY_STRING'];} |