PHP code example of pfinal / ip2region
1. Go to this page and download the library: Download pfinal/ip2region 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/ */
pfinal / ip2region example snippets
nal\Ip2Region\Ip2Region;
$ip2region = new Ip2Region();
$ip = '180.173.2.175';
$info = $ip2region->btreeSearch($ip);
var_dump($info);
//array(2) { ["city_id"]=> int(995) ["region"]=> string(40) "中国|华东|上海市|上海市|电信" }