function chooseLang () { global $wiki_Languages; $pref=array(); foreach(explode(',', $_SERVER["HTTP_ACCEPT_LANGUAGE"]) as $lang) if (preg_match('/^([a-z]+)[^;]*;q=([0-9.]+)/i', $lang . ';q=1.0', $split)) $pref[sprintf("%f%d", $split[2], rand(0,9999))]=strtolower($split[1]); krsort($pref); $junk_1 = array_intersect($pref, $wiki_Languages); $junk_2 = array_merge( $junk_1, $wiki_Languages); return array_shift( $junk_2 ); }