使用codehelper.io显示基于IP位置的状态缩写


Display State abbreviation based on IP location using codehelper.io

有人使用过codehelper.io.php脚本来获取基于ip的用户位置吗?如果是的话,有人能帮我想出如何呼应每个州的缩写吗。

例如:

纽约=纽约

加利福尼亚=CA

<?php
 // 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']."";
 echo $visitor_location['RegionName'];

?>

不幸的是,如果不设置从RegionName到2位美国州代码的映射,您就无法做到这一点。

以下是使用此类从IP地址返回的元素。

IP
ContinentCode
ContinentName
CountryCode2
CountryCode3
Country
CountryName
RegionName
CityName
CityLatitude
CityLongitude
CountryLatitude
CountryLongitude
LocalTimeZone
REMOTE_ADDR
HTTP_X_FORWARDED_FOR
CallingCode
Population
AreaSqKm
GDP_USD
Capital
Electrical
Languages
Currency
Flag