We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

oriolgual on 07/05/07


Tagged


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

Hirmine


Obtenir idioma del navegador


Published in: PHP 


  1. function getIdiomaNavegador ()
  2. {
  3. if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]))
  4. {
  5. $idiomes = explode(",", $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
  6. for($i = 0;$i < count($idiomes);$i++)
  7. {
  8. if (strlen($idiomes[$i]) > 2) $idiomes[$i] = substr($idiomes[$i], 0, 2);
  9. if (in_array($idiomes[$i], $this->IDIOMES_COMPARTIR))
  10. {
  11. $idioma = array_keys($this->IDIOMES_COMPARTIR, $idiomes[$i]);
  12. return ($idioma[0] + 1);
  13. }
  14. }
  15. }
  16. return 1;

Report this snippet 

You need to login to post a comment.