sukohi/country-code

基于iso 3166-1的国家代码,包括国家名称、alpha-2代码、alpha-3代码或数字代码,适用于PHP

1.0.1 2016-09-23 10:18 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:36:48 UTC


README

基于iso 3166-1的国家代码,包括国家名称、alpha-2代码、alpha-3代码或数字代码,适用于PHP

演示

安装

执行composer命令。

composer require sukohi/country-code:1.*

用法

$country_code = new \Sukohi\CountryCode\CountryCode();
$mode = 'alpha-2';  // or alpha-3, numeric (skippable)

// Array
$country_data = $country_code->getArray($mode);
print_r($country_data);

// Country Name
$key = 'US';
$mode = 'alpha-2';  // or alpha-3, numeric (skippable)
$locale = 'en';     // (skippable)
echo $country_code->countryName($key, $mode, $locale);  // United States

贡献

如果您能将国家名称翻译成您的母语,请在assets/csv/country_codes.csv中添加这些名称。
如果您愿意创建一个pull request,我会很高兴。
谢谢!

许可证

本软件包采用MIT许可证。
版权所有 2016 Sukohi Kuhoh