agallou/部门

法国部门列表

v0.1.0 2014-02-01 12:31 UTC

This package is auto-updated.

Last update: 2024-08-29 03:27:10 UTC


README

使用方法

获取标签

$departements = new \agallou\Departements\Collection();
var_dump($departements->getLabel('29'));
//string(10) "Finistère"

获取完整表格

$departements = new \agallou\Departements\Collection();
var_dump($departements->getAll());

如果参数没有用零填充,则获取标签

$departements = new \agallou\Departements\Collection();
var_dump($departements->getLabel(1, true));
//string(3) "Ain"

该集合实现了ArrayIterator,因此可以遍历它

$departements = new \agallou\Departements\Collection();
foreach ($departements as $code => $label) {
  var_dump($code, $label);
}
//string(2) "01"
//string(3) "Ain"
//string(2) "02"
//string(5) "Aisne"
//...
//string(7) "Mayotte"

也可以这样访问标签

$departements = new \agallou\Departements\Collection();
var_dump($departements['69']);
//string(6) "Rhône"