• PHP Video Tutorials

PHP - geoip_record_by_name()



The geoip_record_by_name() function can return the detailed city information found in GeoIP Database.

Syntax

array geoip_record_by_name( string $hostname )

The geoip_record_by_name() function can return the record information corresponding to hostname or IP address.

The geoip_record_by_name() function is available for both GeoLite City Edition and Commercial GeoIP City 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:

  • continent_code − Two letter continent code
  • country_code − Two letter country code
  • country_code3 − Three letter country code
  • country_name − The country name
  • region − The region code
  • city − The city
  • postal_code − The Postal Code, FSA or Zip Code
  • latitude − The Latitude as signed double
  • longitude − The Longitude as signed double
  • dma_code − Designated Market Area code (USA and Canada only)
  • area_code − The PSTN area code

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

Example

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