承接 optiosteam/belgian-region-zip 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

optiosteam/belgian-region-zip

最新稳定版本:1.0.0

Composer 安装命令:

composer require optiosteam/belgian-region-zip

包简介

PHP library for Belgian zip codes and cities per region/province

README 文档

README

The data in this library is based on the public data provided by bpost (https://www.bpost.be/nl/postcodes).

Zip codes are ordered by region/province. For these regions the ISO 3166 code is used (https://www.iso.org/obp/ui/#iso:code:3166:BE)

Installation

Requirement: PHP version >=7.2

composer require optiosteam/belgian-region-zip

Description

This library contains 1 main class BelgianRegionZipHelper with 3 static functions:

  • BelgianRegionZipHelper::getRegions() returns all Belgian Regions/Provinces
  • BelgianRegionZipHelper::getZipCodesByRegionIsoCode(string $regionIsoCode) returns all zip codes within a certain region/province
  • BelgianRegionZipHelper::getMunicipalitiesByZipCode(string $zipCode, ?string $regionIsoCode = null, ?string $languageCode = null) returns all municipalities for a certain zip code. Optionally you can pass the region and the language. NOTE: bpost only provides translations of municipalities in Brussels, for other regions the Dutch and French name are the same.

For more information on the data structure, you can look at the json data in src/Data

Examples

getMunicipalitiesByZipCode

echo '<pre>';
var_dump(BelgianRegionZipHelper::getMunicipalitiesByZipCode(1000));
echo '</pre>';

returns:

array(2) {
  'nl' =>
  array(1) {
    [0] =>
    string(7) "Brussel"
  }
  'fr' =>
  array(1) {
    [0] =>
    string(9) "Bruxelles"
  }
}
echo '<pre>';
var_dump(BelgianRegionZipHelper::getMunicipalitiesByZipCode(8000, 'BE-Vwv', 'nl'));
echo '</pre>';

returns:

array(2) {
  [0] =>
  string(6) "Brugge"
  [1] =>
  string(9) "Koolkerke"
}

getZipCodesByRegionIsoCode

echo '<pre>';
var_dump(BelgianRegionZipHelper::getZipCodesByRegionIsoCode('BE-BRU'));
echo '</pre>';

returns:

array(22) {
  [0] =>
  int(1000)
  [1] =>
  int(1020)
  [2] =>
  int(1030)
  [3] =>
  int(1040)
  [4] =>
  int(1050)
  [5] =>
  int(1060)
  [6] =>
  int(1070)
  [7] =>
  int(1080)
  [8] =>
  int(1081)
  [9] =>
  int(1082)
  [10] =>
  int(1083)
  [11] =>
  int(1090)
  [12] =>
  int(1120)
  [13] =>
  int(1130)
  [14] =>
  int(1140)
  [15] =>
  int(1150)
  [16] =>
  int(1160)
  [17] =>
  int(1170)
  [18] =>
  int(1180)
  [19] =>
  int(1190)
  [20] =>
  int(1200)
  [21] =>
  int(1210)
}

Contributing

Feel free to submit pull requests for improvements & bug fixes.

MIT License

统计信息

  • 总下载量: 75.11k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知