PHPackages                             thalidzhokov/country-codes - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. thalidzhokov/country-codes

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

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

1.0.7(1y ago)13111.5k↓17.7%7GPL-3.0-or-laterPHPPHP ^5.6 || ^7.0 || ^8.0

Since Oct 27Pushed 1y ago3 watchersCompare

[ Source](https://github.com/thalidzhokov/country-codes)[ Packagist](https://packagist.org/packages/thalidzhokov/country-codes)[ RSS](/packages/thalidzhokov-country-codes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)DependenciesVersions (6)Used By (0)

PHP Class CountryCodes
======================

[](#php-class-countrycodes)

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

1. **alpha2** ISO-3166-1 alpha-2 [https://en.wikipedia.org/wiki/ISO\_3166-1\_alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
2. **alpha3** ISO-3166-1 alpha-3 [https://en.wikipedia.org/wiki/ISO\_3166-1\_alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3)
3. **numeric** ISO-3166-1 numeric [https://en.wikipedia.org/wiki/ISO\_3166-1\_numeric](https://en.wikipedia.org/wiki/ISO_3166-1_numeric)
4. **isd** Internatiguonal Subscriber Dialing code [https://en.wikipedia.org/wiki/List\_of\_country\_calling\_codes](https://en.wikipedia.org/wiki/List_of_country_calling_codes)
5. **continentCode** Continent Code
6. **continent** Continent Name
7. **country** Country Name
8. **countryFull** Country Full Name
9. **emoji** Emoji Flag

Installation
------------

[](#installation)

Install via Composer

```
composer require thalidzhokov/country-codes
```

OR include *CountryCodes.php* in your PHP code

```
require_once('CountryCodes.php');
```

Usage
-----

[](#usage)

#### Change default language

[](#change-default-language)

```
\CountryCodes::$language = 'ru';
```

#### Method **get()**

[](#method-get)

Get array **key =&gt; value**

```
\CountryCodes::get('alpha2', 'country');
```

Return

```
array (
  'AB' => 'Abkhazia',
  'AD' => 'Andorra',
  ...,
  'AI' => 'Anguilla',
  'AL' => 'Albania',
  'AM' => 'Armenia',
  ...,
  'US' => 'USA',
  ...
)

```

#### Method **get2()**

[](#method-get2)

Get array with multiple values **key =&gt; \[value1, value2, ...\]**

```
\CountryCodes::get2('alpha3', ['alpha2', 'continentCode', 'emoji']);
```

Return

```
array (
  'ABH' =>
  array (
    'alpha2' => 'AB',
    'continentCode' => 'AS',
    'emoji' => '',
  ),
  'AND' =>
  array (
    'alpha2' => 'AD',
    'continentCode' => 'EU',
    'emoji' => '&#x1F1E6;&#x1F1E9;',
  ),
  'ARE' =>
  array (
    'alpha2' => 'AE',
    'continentCode' => 'AS',
    'emoji' => '&#x1F1E6;&#x1F1EA;',
  ),
  ...
)

```

#### Method **getByContinent()**

[](#method-getbycontinent)

Get array **key =&gt; 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()**

[](#method-getemojibyalpha2)

Get emoji flag code by alpha2

```
\CountryCodes::getEmojiByAlpha2('ZW');
```

Return

```
&#x1F1FF;&#x1F1FC;

```

#### Method **getEmojiByAlpha3()**

[](#method-getemojibyalpha3)

Get emoji flag code by aplha3

```
\CountryCodes::getEmojiByAlpha3('ZMB');
```

Return

```
&#x1F1FF;&#x1F1F2;

```

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance47

Moderate activity, may be stable

Popularity41

Moderate usage in the ecosystem

Community11

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~681 days

Total

5

Last Release

399d ago

PHP version history (3 changes)1.0.1PHP ^5.6 || ^7.0

1.0.6PHP &gt;=5.6 &lt;=8.4

1.0.7PHP ^5.6 || ^7.0 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/fefcd2b3607ddc8edba8665c1ff4562e181940447b33ebace65ba86a7466f030?d=identicon)[thalidzhokov](/maintainers/thalidzhokov)

---

Top Contributors

[![thalidzhokov](https://avatars.githubusercontent.com/u/5680364?v=4)](https://github.com/thalidzhokov "thalidzhokov (22 commits)")

---

Tags

iso3166numericISO 3166-1country codesalpha-2alpha-3international organization for standardizationisdinternatiguonal subscriber dialingiddinternational direct dialingcountry calling codescountry dial in codes

### Embed Badge

![Health badge](/badges/thalidzhokov-country-codes/health.svg)

```
[![Health](https://phpackages.com/badges/thalidzhokov-country-codes/health.svg)](https://phpackages.com/packages/thalidzhokov-country-codes)
```

###  Alternatives

[league/iso3166

ISO 3166-1 PHP Library

70036.3M116](/packages/league-iso3166)[stefangabos/world_countries

Constantly updated lists of world countries, territories and areas of geographical interest, with associated alpha-2, alpha-3 and numeric codes as defined by the ISO 3166-1 standard, available in multiple formats and languages, with national flags included

1.6k122.7k1](/packages/stefangabos-world-countries)[payum/iso4217

ISO 4217 PHP Library

16312.1M5](/packages/payum-iso4217)[matriphe/iso-639

PHP library to convert ISO-639-1 code to language name.

503.3M6](/packages/matriphe-iso-639)[petercoles/multilingual-country-list

Lookup Objects for ISO 3166 Country Names and Codes

149374.6k4](/packages/petercoles-multilingual-country-list)[sameer-shelavale/php-countries-array

PHP class to get array of countries names with ISO\_3166-1 alpha-2, alpha-3, numeric codes, ISD codes and continent

34408.8k1](/packages/sameer-shelavale-php-countries-array)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
