All Projects → lybc → php-gb2260

lybc / php-gb2260

Licence: other
中华人民共和国国家标准 GB/T 2260 行政区划代码 php sdk

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to php-gb2260

GB2260.java
中华人民共和国行政区划代码(GB/T 2260),数据库Java版实现。
Stars: ✭ 27 (-40%)
Mutual labels:  gb2260

php-gb2260

中华人民共和国国家标准 GB/T 2260 行政区划代码 php 封装

Installing

composer require lybc/php-gb2260

Usage

use Lybc\PhpGB2260\GB2260;

$provinceAreaCode = 360000; // 江西省
$cityAreaCode = 360300;     // 萍乡市
$districtAreaCode = 360313; // 湘东区


// 判断 code 是否省市区
GB2260::areaCode($provinceAreaCode)->isProvince();
GB2260::areaCode($provinceAreaCode)->isCity();
GB2260::areaCode($provinceAreaCode)->isDistrict();

// 根据 code 获取省市区名称
GB2260::areaCode(360313)->getCurrent(); // 获取当前代码的名称
GB2260::areaCode(360300)->getProvince(); // 根据市号获取所在省的名称
GB2260::areaCode(360313)->getCity(); // 根据区号获取所在市的名称
GB2260::areaCode(360313)->getDistrict(); // 根据区号获取名称

GB2260::areaCode(360300)->getDistrict(); // 根据市号获取所有区的名称,为 code => name 的数组

// 按照自定义格式输出
GB2260::areaCode(360300)->format('{p}, {c}, {d}'); // 输出江西省, 萍乡市, 湘东区, 只支持{p}/{c}/{d}

$area = new GB2260(360300); // 等价于 GB2260::areaCode(360300)

采集 China GB2260 数据

php ./scripts/cn.php 地址

地址例如 http://www.mca.gov.cn/article/sj/tjbz/a/2017/201707/201708241433.html 则采集命令为 php ./scripts/cn.php http://www.mca.gov.cn/article/sj/tjbz/a/2017/201707/201708241433.html

License

MIT

Thanks

package-builder @ overtrue

gb2260

gb2260.php

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].