Obtenir idioma del navegador
Copy this code and paste it in your HTML
function getIdiomaNavegador ()
{
if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
$idiomes = explode(",", $_SERVER["HTTP_ACCEPT_LANGUAGE"]); for($i = 0;$i < count($idiomes);$i++) {
if (strlen($idiomes[$i]) > 2) $idiomes[$i] = substr($idiomes[$i], 0, 2); if (in_array($idiomes[$i], $this->IDIOMES_COMPARTIR)) {
$idioma = array_keys($this->IDIOMES_COMPARTIR, $idiomes[$i]); return ($idioma[0] + 1);
}
}
}
return 1;
Report this snippet
Comments
Subscribe to comments