PHP code example of cimus / ip-geo-base
1. Go to this page and download the library: Download cimus/ip-geo-base library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cimus / ip-geo-base example snippets
use Cimus\IpGeoBase\Util\IpGeoBaseUtil;
$path = __DIR__ . '/DB';
$util = new IpGeoBaseUtil();
$util->loadArchive($path);
$util->convertInBinary($path);
use Cimus\IpGeoBase\IpGeoBase;
$path = __DIR__ . '/DB';
$search = new IpGeoBase($path);
$info = $search->search('176.121.128.1');
print_r($info);
Array
(
[country] => RU
[city] => Чебоксары
[region] => Республика Чувашия
[district] => Приволжский федеральный округ
[latitude] => 56.137451
[longitude] => 47.244030
[ip_start] => 176.121.128.0
[ip_stop] => 176.121.191.255
)
bash
$ php composer.phar