composer require 'ruchee/phone_attribution'
<?php
include_once __DIR__.'/vendor/autoload.php';
use Ruchee\PhoneAttribution\Parse;
$parse = new Parse();
$data = $parse->parseOne('13713462969');
print_r($data);
// 输出结果
Array
(
[status] => 1
[info] => 解析成功
[data] => Array
(
[province] => 广东
[city] => 东莞
[postcode] => 523000
[prefix] => 0769
[spname] => **移动
)
)
<?php
include_once __DIR__.'/vendor/autoload.php';
use Ruchee\PhoneAttribution\Parse;
$parse = new Parse();
$phone_list = [
'18520796150',
'18745222111',
];
$data = $parse->parseList($phone_list);
print_r($data);
// 输出结果
Array
(
[status] => 1
[info] => 解析成功
[data] => Array
(
[18520796150] => Array
(
[province] => 广东
[city] => 广州
[postcode] => 510000
[prefix] => 020
[spname] => **联通
)
[18745222111] => Array
(
[province] => 黑龙江
[city] => 齐齐哈尔
[postcode] => 161000
[prefix] => 0452
[spname] => **移动
)
)
)
<?php
include_once __DIR__.'/vendor/autoload.php';
use Ruchee\PhoneAttribution\Parse;
$parse = new Parse(__DIR__.'/phone.dat');
// 更新数据源
// wget -c https://github.com/xluohome/phonedata/blob/master/phone.dat?raw=true -O phone.dat