PHP code example of looking4soul / ipgeo

1. Go to this page and download the library: Download looking4soul/ipgeo 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/ */

    

looking4soul / ipgeo example snippets



k = 'path/to/GeoLite2-City-Blocks-IPv4.csv';
$location = 'path/to/GeoLite2-City-Locations-zh-CN.csv';
$ipgeo = new \Looking4soul\IpGeo\IpGeo();
$ipgeo->import($block, $location);



o = new \Looking4soul\IpGeo\IpGeo();
var_dump($ipgeo->find_city_by_ip('140.237.24.176'));
/*expected output is array of city and country in zh-CN.
array(2) {
  [0]=>
  string(0) ""
  [1]=>
  string(6) "中国"
}
*/