phpuef/country
最新稳定版本:v1.0.1
Composer 安装命令:
composer require phpuef/country
包简介
README 文档
README
Country
This package provides functions to search for country information (ISO 3166-1) based on their country codes (Alpha-2, Alpha-3, Numeric) and names. It is designed for easy integration into applications that need to work with country codes or names.
Versions
Also available in other languages
Installation
composer require phpuef/country
Usage
Country Class
Each country is represented by the Country class, which contains the following fields:
name: The country's name (in English).alpha2: The two-letter country code (ISO 3166-1 alpha-2).alpha3: The three-letter country code (ISO 3166-1 alpha-3).numeric: The numeric country code (ISO 3166-1 numeric).
Functions
FindByAlpha2(string $alpha2): ?Country
This function searches for a country by its two-letter Alpha-2 code.
<?php use Phpuef\Country\Countries; class Example { public function findCZ() { $country = Countries::FindByAlpha2("CZ") if ($country !== null) { echo "Country Name: " + $country?->name; echo "Alpha-2 Code:: " + $country?->alpha2; } } }
FindByAlpha3(string $alpha3): ?Country
This function searches for a country by its three-letter Alpha-3 code.
<?php use Phpuef\Country\Countries; class Example { public function findCZ() { $country = Countries::FindByAlpha3("CZE") if ($country !== null) { echo "Country Name: " + $country?->name; echo "Alpha-3 Code:: " + $country?->alpha3; } } }
FindByName *Country
This function searches for a country by its name (english).
<?php use Phpuef\Country\Countries; class Example { public function findCZ() { $country = Countries::FindByName("Czechia") if ($country !== null) { echo "Country Name: " + $country?->name; echo "Alpha-2 Code:: " + $country?->alpha2; echo "Alpha-3 Code:: " + $country?->alpha3; } } }
Contributing
Read Contributing
Contributors
Join our Discord Community! 🎉
Click above to join our community on Discord!
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-18
