thalidzhokov / country-codes
CountryCodes PHP Class to get array of countries with ISO 3166-1 alpha-2, ISO 3166-1 alpha-3, ISO 3166-1 numeric and ISD codes it can provide following information related to country
Installs: 90 095
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 3
Forks: 7
Open Issues: 1
Requires
- php: ^5.6 || ^7.0
This package is auto-updated.
Last update: 2024-12-17 21:00:29 UTC
README
CountryCodes PHP Class to get array of countries with ISO 3166-1 alpha-2, ISO 3166-1 alpha-3, ISO 3166-1 numeric and ISD codes it can provide following information related to country
- alpha2 ISO-3166-1 alpha-2 https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
- alpha3 ISO-3166-1 alpha-3 https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
- numeric ISO-3166-1 numeric https://en.wikipedia.org/wiki/ISO_3166-1_numeric
- isd Internatiguonal Subscriber Dialing code https://en.wikipedia.org/wiki/List_of_country_calling_codes
- continentCode Continent Code
- continent Continent Name
- country Country Name
- countryFull Country Full Name
- emoji Emoji Flag http://unicode.org/emoji/charts/emoji-ordering.html#country-flag
Installation
Install via Composer
composer require thalidzhokov/country-codes
OR include CountryCodes.php in your PHP code
require_once('CountryCodes.php');
Usage
Change default language
\CountryCodes::$language = 'ru';
Method get()
Get array key => value
\CountryCodes::get('alpha2', 'country');
Return
array (
'AB' => 'Abkhazia',
'AD' => 'Andorra',
...,
'AI' => 'Anguilla',
'AL' => 'Albania',
'AM' => 'Armenia',
...,
'US' => 'USA',
...
)
Method get2()
Get array with multiple values key => [value1, value2, ...]
\CountryCodes::get2('alpha3', ['alpha2', 'continentCode', 'emoji']);
Return
array (
'ABH' =>
array (
'alpha2' => 'AB',
'continentCode' => 'AS',
'emoji' => '',
),
'AND' =>
array (
'alpha2' => 'AD',
'continentCode' => 'EU',
'emoji' => '🇦🇩',
),
'ARE' =>
array (
'alpha2' => 'AE',
'continentCode' => 'AS',
'emoji' => '🇦🇪',
),
...
)
Method getByContinent()
Get array key => value by continent
\CountryCodes::getByContinent('alpha3', 'countryFull', 'EU');
Return
array (
...,
'BEL' => 'Belgium',
'BGR' => 'Bulgaria',
'BLR' => 'Belarus',
'CHE' => 'Swiss Confederation',
'CZE' => 'Czech Republic',
'DEU' => 'Germany',
...
)
Method getEmojiByAlpha2()
Get emoji flag code by alpha2
\CountryCodes::getEmojiByAlpha2('ZW');
Return
🇿🇼
Method getEmojiByAlpha3()
Get emoji flag code by aplha3
\CountryCodes::getEmojiByAlpha3('ZMB');
Return
🇿🇲