Ip to Country

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInPrint this page

This is the most accurate plugin of it’s kind which provide into an easy to use format the country details for a given IP.

This works on booth IPv4 and IPv6 protocols. The database is stored locally which will ensure a great speed for the code and a prompt response from the plugin class. The usage is extremely simple, only the IP is need to be provided otherwise it will use the client IP.

Example of usage

$ip2c = new ip2country();
$country_code = $ip2c->get_country_code();

This will return the following array:

  • $country_code[‘country_name’] – Country Name for the client (computer)
  • $country_code[‘country_code’] – Country ISO Code for the client (computer)

Since no IP was specified, the class will automatically identify the computer IP and use that.

If you need to get information’s for a given IP, this need to be provided for the get_country_code() as it show next:

$ip2c = new ip2country();
$ip = ‘’;
$country_code = $ip2c->get_country_code($ip);

The information’s are very accurate as it use the latest available information’s for that purpose.