ivoglent/ip2c

There is no license information available for the latest version (1.0.0) of this package.

Convert IP address to country code or name

1.0.0 2019-08-30 02:45 UTC

This package is auto-updated.

Last update: 2024-11-29 05:51:12 UTC


README

Detect location of an IP live area, country code and country name.

Usage

require 'vendor/autoload.php';
use ivoglent\ip2c\IpLocator;

$ip = '186.95.255.255;
$ipLocator = new IpLocator($ip);
if ($ipLocator->analysis()) {
    echo sprintf('%s : %s, %s, %s', $ip, $ipLocator->getArea(), $ipLocator->getCountryCode(), $ipLocator->getCoutryName()) . PHP_EOL;
} else {
    echo 'Can not detect this IP address' . PHP_EOL;
}