agallou / regions
法国地区列表
v0.2.0
2016-04-24 20:52 UTC
Requires (Dev)
- atoum/atoum: 0.0.1
- m6web/coke: 1.0.0
This package is auto-updated.
Last update: 2024-08-29 03:15:47 UTC
README
使用方法
获取标签
$regions = new \agallou\Regions\Collection(); var_dump($regions->get('11')->getLabel()); //string(10) "Ile-de-France"
如果参数未用零填充,则获取标签
$regions = new \agallou\Regions\Collection(); var_dump($regions->getLabel(2, true)); //string(10) "Martinique"
获取该地区的部门代码
$regions = new \agallou\Regions\Collection(); var_dump($regions->get('82')->getCodesDepartements()); //array(8) { //[0]=> // string(2) "01" //[1]=> // string(2) "07" //[2]=> // string(2) "26" //[3]=> // string(2) "38" //[4]=> // string(2) "42" //[5]=> // string(2) "69" //[6]=> // string(2) "73" //[7]=> // string(2) "74" //}
该集合实现了ArrayIterator,因此可以遍历
$departements = new \agallou\Departements\Collection(); foreach ($departements as $code => $label) { var_dump($code, $label); } //int(42) //string(6) "Alsace" //int(72) //string(9) "Aquitaine" //int(83) //string(8) "Auvergne" //... //int(82) //string(12) "Rhône-Alpes"
Regions 2016
根据2015年1月16日第2015-29号关于地区划分的法律,新的地区划分也可用。
该划分可通过Collection2016
类获取
$regions = new \agallou\Regions\Collection2016(); var_dump($regions->get('84')->getLabel()); //string(10) "Auvergne-Rhône-Alpes"