Ecco a te

Codice PHP:
<?php $default 'lang/it/'$redirect = array(      'fr' => 'lang/fr/index.php',                         'it' => 'lang/it/',                         'es' => 'lang/es/',                         'pt' => 'lang/pt/index.php', );   ## / config ## // get the language string proposed by the browser if there is one function lang_from_browser() {     // it;q=1.0,fr;q=0.9,en;q=0.8 OR fr-ch     $lang_list = $_SERVER['HTTP_ACCEPT_LANGUAGE'];     //echo $lang_list ;exit();      $lang_block = explode(',', $lang_list);     $lang_ar = array();     foreach ($lang_block as $t) {         array_push($lang_ar, strtolower(substr(trim($t), 0,2)));     }         return $lang_ar; } // redirect to the browser language if there is one function redirect($lang){     global $redirect;     if(count($lang) > 0){       foreach($lang as $l){           if(array_key_exists($l,$redirect)){               header('Location: '.$redirect[$l]);               die();           }       }     }     return true; } ## redirect ## if(redirect(lang_from_browser())){     header('Location: '.$default);     die(); } ?>