• PHP Video Tutorials

PHP - geoip_region_by_name()



The geoip_region_by_name() function can get the country code and region.

Syntax

array geoip_region_by_name( string $hostname )

The geoip_region_by_name() function can return the country and region corresponding to hostname or IP address.

This function is currently available only to users who have bought a commercial GeoIP Region Edition. A warning can be issued if a proper database can't be located.

The names of the different keys of the returning associative array are as follows:

  • country_code : Two letter country code
  • region : The region code

The geoip_region_by_name() function can return an associative array on success, or false if the address can't be found in the database.

Example

<?php
   $region = geoip_region_by_name("www.tutorialspoint.com");
   if($region) {
      print_r($region);
   }
?>
php_function_reference.htm
Advertisements