jasmine2 / mobile-region-of-china
Attribution of Chinese mobile phone number
Installs: 24
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 2
pkg:composer/jasmine2/mobile-region-of-china
Requires
- php: ~7.0
Requires (Dev)
- phpunit/phpunit: ~7.0
This package is auto-updated.
Last update: 2026-02-11 18:44:55 UTC
README
- 数据文件来源:[https://github.com/xluohome/phonedata/blob/master/phone.dat]
- 解析算法参考:[https://github.com/shitoudev/phone-location/blob/master/src/PhoneLocation.php]
安装
composer require jasmine2/mobile-region-of-china
使用
<?php
include_once __DIR__.'/vendor/autoload.php';
use jasmine2\MobileRegion\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 jasmine2\MobileRegion\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 jasmine2\MobileRegion\Parse;
$parse = new Parse(__DIR__.'/phone.dat');
// 更新数据源
// wget -c https://github.com/xluohome/phonedata/blob/master/phone.dat?raw=true -O phone.dat