0

Is there a way to determine whether a user has set its locale to Switzerland? I tried

$_SERVER['HTTP_ACCEPT_LANGUAGE']

but this is only giving me "de" as locale. Is there another way or maybe I did something wrong? Is there a free service for IP checks maybe?

Arnie
  • 661
  • 9
  • 20
  • possible duplicate of [How to find country using IP address in PHP?](http://stackoverflow.com/questions/21878058/how-to-find-country-using-ip-address-in-php) – Saty Jun 25 '15 at 10:05
  • This code only checks the language of the browser... – Naruto Jun 25 '15 at 10:10

1 Answers1

0

You can use this php class to get the users location in php.

Once you have the files you can use this code:

<?php 
/* 
 * Website http://www.codehelper.io 
 * Author: khoaofgod@yahoo.com 
 * Any bugs, question, please visit our forum at http://www.codehelper.io 
 */ 

// Required Libraries 
require_once("ip.codehelper.io.php"); 
require_once("php_fast_cache.php"); 

// New Class 
$_ip = new ip_codehelper(); 

// Detect Real IP Address & Location 
$real_client_ip_address = $_ip->getRealIP(); 
$visitor_location = $_ip->getLocation($real_client_ip_address); 

// Output result 
echo $visitor_location['Country']."<br>"; 
echo "<pre>"; 
print_r($visitor_location); 
Aryeh Armon
  • 2,137
  • 2
  • 22
  • 37