how do i get the "nl" or other country codes out of the http_user_agent?
user_agent example:
Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
Printable View
how do i get the "nl" or other country codes out of the http_user_agent?
user_agent example:
Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
You can use GeoIP, the free edition. It can determine someones place by looking at the IP:
http://www.maxmind.com/?rId=google&g...FQ1KQgodoQ-aCw
That is both less accurate and less userfriendly Daevius :wink:
As for your problem: the golden rule of PHP string manipulation rises once again. If you ever feel like you need to do some string manipulation, don't.
http://nl3.php.net/manual/en/reserve...les.server.php
$_SERVER['HTTP_ACCEPT_LANGUAGE'] already holds exactly that value, without any need to parse headers yourself :smile:
$_SERVER['HTTP_ACCEPT_LANGUAGE'] isn't supported by my host.