Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
'AO' => 'Angola',
'AI' => 'Anguilla',
'AQ' => 'Antarctica',
'AG' => 'Antigua And Barbuda',
'AR' => 'Argentina',
'AM' => 'Armenia',
'AW' => 'Aruba',
'AU' => 'Australia',
'AT' => 'Austria',
'AZ' => 'Azerbaijan',
'BS' => 'Bahamas',
'BH' => 'Bahrain',
'BD' => 'Bangladesh',
'BB' => 'Barbados',
'BY' => 'Belarus',
'BE' => 'Belgium',
'BZ' => 'Belize',
'BJ' => 'Benin',
'BM' => 'Bermuda',
'BT' => 'Bhutan',
'BO' => 'Bolivia',
'BA' => 'Bosnia And Herzegovina',
'BW' => 'Botswana',
'BV' => 'Bouvet Island',
'BR' => 'Brazil',
'IO' => 'British Indian Ocean Territory',
'BN' => 'Brunei Darussalam',
'BG' => 'Bulgaria',
'BF' => 'Burkina Faso',
'BI' => 'Burundi',
'KH' => 'Cambodia',
'CM' => 'Cameroon',
'CA' => 'Canada',
'CV' => 'Cape Verde',
'KY' => 'Cayman Islands',
'CF' => 'Central African Republic',
'TD' => 'Chad',
'CL' => 'Chile',
'CN' => 'China',
'CX' => 'Christmas Island',
'CC' => 'Cocos (Keeling) Islands',
'CO' => 'Colombia',
'KM' => 'Comoros',
'CG' => 'Congo',
'CD' => 'Congo, Democratic Republic',
'CK' => 'Cook Islands',
'CR' => 'Costa Rica',
'CI' => 'Cote D\'Ivoire',
'HR' => 'Croatia',
'CU' => 'Cuba',
'CY' => 'Cyprus',
'CZ' => 'Czech Republic',
'DK' => 'Denmark',
'DJ' => 'Djibouti',
'DM' => 'Dominica',
'DO' => 'Dominican Republic',
'EC' => 'Ecuador',
'EG' => 'Egypt',
'SV' => 'El Salvador',
'GQ' => 'Equatorial Guinea',
'ER' => 'Eritrea',
'EE' => 'Estonia',
'ET' => 'Ethiopia',
'FK' => 'Falkland Islands (Malvinas)',
'FO' => 'Faroe Islands',
'FJ' => 'Fiji',
'FI' => 'Finland',
'FR' => 'France',
'GF' => 'French Guiana',
'PF' => 'French Polynesia',
'TF' => 'French Southern Territories',
'GA' => 'Gabon',
'GM' => 'Gambia',
'GE' => 'Georgia',
'DE' => 'Germany',
'GH' => 'Ghana',
'GI' => 'Gibraltar',
'GR' => 'Greece',
'GL' => 'Greenland',
'GD' => 'Grenada',
'GP' => 'Guadeloupe',
'GU' => 'Guam',
'GT' => 'Guatemala',
'GG' => 'Guernsey',
'GN' => 'Guinea',
'GW' => 'Guinea-Bissau',
'GY' => 'Guyana',
'HT' => 'Haiti',
'HM' => 'Heard Island & Mcdonald Islands',
'VA' => 'Holy See (Vatican City State)',
'HN' => 'Honduras',
'HK' => 'Hong Kong',
'HU' => 'Hungary',
'IS' => 'Iceland',
'IN' => 'India',
'ID' => 'Indonesia',
'IR' => 'Iran, Islamic Republic Of',
'IQ' => 'Iraq',
'IE' => 'Ireland',
'IM' => 'Isle Of Man',
'IL' => 'Israel',
'IT' => 'Italy',
'JM' => 'Jamaica',
'JP' => 'Japan',
'JE' => 'Jersey',
'JO' => 'Jordan',
'KZ' => 'Kazakhstan',
'KE' => 'Kenya',
'KI' => 'Kiribati',
'KR' => 'Korea',
'KW' => 'Kuwait',
'KG' => 'Kyrgyzstan',
'LA' => 'Lao People\'s Democratic Republic',
'LV' => 'Latvia',
'LB' => 'Lebanon',
'LS' => 'Lesotho',
'LR' => 'Liberia',
'LY' => 'Libyan Arab Jamahiriya',
'LI' => 'Liechtenstein',
'LT' => 'Lithuania',
'LU' => 'Luxembourg',
'MO' => 'Macao',
'MK' => 'Macedonia',
'MG' => 'Madagascar',
'MW' => 'Malawi',
'MY' => 'Malaysia',
'MV' => 'Maldives',
'ML' => 'Mali',
'MT' => 'Malta',
'MH' => 'Marshall Islands',
'MQ' => 'Martinique',
'MR' => 'Mauritania',
'MU' => 'Mauritius',
'YT' => 'Mayotte',
'MX' => 'Mexico',
'FM' => 'Micronesia, Federated States Of',
'MD' => 'Moldova',
'MC' => 'Monaco',
'MN' => 'Mongolia',
'ME' => 'Montenegro',
'MS' => 'Montserrat',
'MA' => 'Morocco',
'MZ' => 'Mozambique',
'MM' => 'Myanmar',
'NA' => 'Namibia',
'NR' => 'Nauru',
'NP' => 'Nepal',
'NL' => 'Netherlands',
'AN' => 'Netherlands Antilles',
'NC' => 'New Caledonia',
'NZ' => 'New Zealand',
'NI' => 'Nicaragua',
'NE' => 'Niger',
'NG' => 'Nigeria',
'NU' => 'Niue',
'NF' => 'Norfolk Island',
'MP' => 'Northern Mariana Islands',
'NO' => 'Norway',
'OM' => 'Oman',
'PK' => 'Pakistan',
'PW' => 'Palau',
'PS' => 'Palestinian Territory, Occupied',
'PA' => 'Panama',
'PG' => 'Papua New Guinea',
'PY' => 'Paraguay',
'PE' => 'Peru',
'PH' => 'Philippines',
'PN' => 'Pitcairn',
'PL' => 'Poland',
'PT' => 'Portugal',
'PR' => 'Puerto Rico',
'QA' => 'Qatar',
'RE' => 'Reunion',
'RO' => 'Romania',
'RU' => 'Russian Federation',
'RW' => 'Rwanda',
'BL' => 'Saint Barthelemy',
'SH' => 'Saint Helena',
'KN' => 'Saint Kitts And Nevis',
'LC' => 'Saint Lucia',
'MF' => 'Saint Martin',
'PM' => 'Saint Pierre And Miquelon',
'VC' => 'Saint Vincent And Grenadines',
'WS' => 'Samoa',
'SM' => 'San Marino',
'ST' => 'Sao Tome And Principe',
'SA' => 'Saudi Arabia',
'SN' => 'Senegal',
'RS' => 'Serbia',
'SC' => 'Seychelles',
'SL' => 'Sierra Leone',
'SG' => 'Singapore',
'SK' => 'Slovakia',
'SI' => 'Slovenia',
'SB' => 'Solomon Islands',
'SO' => 'Somalia',
'ZA' => 'South Africa',
'GS' => 'South Georgia And Sandwich Isl.',
'ES' => 'Spain',
'LK' => 'Sri Lanka',
'SD' => 'Sudan',
'SR' => 'Suriname',
'SJ' => 'Svalbard And Jan Mayen',
'SZ' => 'Swaziland',
'SE' => 'Sweden',
'CH' => 'Switzerland',
'SY' => 'Syrian Arab Republic',
'TW' => 'Taiwan',
'TJ' => 'Tajikistan',
'TZ' => 'Tanzania',
'TH' => 'Thailand',
'TL' => 'Timor-Leste',
'TG' => 'Togo',
'TK' => 'Tokelau',
'TO' => 'Tonga',
'TT' => 'Trinidad And Tobago',
'TN' => 'Tunisia',
'TR' => 'Turkey',
'TM' => 'Turkmenistan',
'TC' => 'Turks And Caicos Islands',
'TV' => 'Tuvalu',
'UG' => 'Uganda',
'UA' => 'Ukraine',
'AE' => 'United Arab Emirates',
'GB' => 'United Kingdom',
'US' => 'United States',
'UM' => 'United States Outlying Islands',
'UY' => 'Uruguay',
'UZ' => 'Uzbekistan',
'VU' => 'Vanuatu',
'VE' => 'Venezuela',
'VN' => 'Viet Nam',
'VG' => 'Virgin Islands, British',
'VI' => 'Virgin Islands, U.S.',
'WF' => 'Wallis And Futuna',
'EH' => 'Western Sahara',
'YE' => 'Yemen',
'ZM' => 'Zambia',
'ZW' => 'Zimbabwe',
);
?>
@DelphicOkami

This comment has been minimized.

Copy link

commented Nov 28, 2013

Thank you very much for this

@mbardelmeijer

This comment has been minimized.

Copy link

commented Dec 9, 2013

Thanks!

@Rikstam

This comment has been minimized.

Copy link

commented Jan 16, 2014

Just what I needed, thank you very much!

@colegatron

This comment has been minimized.

Copy link

commented Feb 5, 2014

Thank you to save us time in a simple but time consuming thing!!

@ghost

This comment has been minimized.

Copy link

commented Feb 6, 2014

So much time saved. THX.

@Dinaris

This comment has been minimized.

Copy link

commented Feb 12, 2014

You are the best!!! Very useful array. Thank you very much!

@andrewsuzuki

This comment has been minimized.

Copy link

commented Feb 27, 2014

Awesome, thanks.

@julien-c

This comment has been minimized.

Copy link

commented Mar 27, 2014

Here it is in Composer-packaged form: https://github.com/julien-c/iso3166

Cheers!

@gnclmorais

This comment has been minimized.

Copy link

commented Mar 31, 2014

Awesome, this saved me so much time...! :D

@jorgeorpinel

This comment has been minimized.

Copy link

commented Apr 3, 2014

@MackieeE

This comment has been minimized.

Copy link

commented May 1, 2014

Thank you very much! :)

@jworksuk

This comment has been minimized.

Copy link

commented May 22, 2014

Thanks!!!

@lifeofguenter

This comment has been minimized.

Copy link

commented Jun 9, 2014

Eclipse exploded, but all fine now. Thank you so much!

@daslicht

This comment has been minimized.

Copy link

commented Jun 29, 2014

Thank you !

@shahriyar1369

This comment has been minimized.

Copy link

commented Jul 9, 2014

This What I Need .... Thank You Very Much ;)

@larryweya

This comment has been minimized.

Copy link

commented Jul 28, 2014

Thanks a lot, needed this.

@RichUK

This comment has been minimized.

Copy link

commented Aug 9, 2014

good start but kept falling over in my c# code as some are incorrect,
For example, the United Kingdom, whose alpha-2 code is GB, uses .uk instead of .gb
EL (not GR) is used to represent Greece

Theres no eu, iso 3166-1_apha 2 could be others need adding/changing to comply
http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

@jk3us

This comment has been minimized.

Copy link

commented Aug 25, 2014

Is there a version of this that either includes only countries (and not subdivisions/territories), or has them labeled as such? For example, if we want to offer a drop-down of country names, we don't want people to be able to choose Guam, because they are actually in a territory of the United States.

@omlid

This comment has been minimized.

Copy link

commented Sep 5, 2014

Thank you!

@adamthebig

This comment has been minimized.

Copy link

commented Sep 11, 2014

+1000

@miromana

This comment has been minimized.

Copy link

commented Sep 16, 2014

Your are missing 4 countries from http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2, also some of the names do not match their original name, you can update your array with the following list:

AF | Afghanistan
AX | Åland Islands
AL | Albania
DZ | Algeria
AS | American Samoa
AD | Andorra
AO | Angola
AI | Anguilla
AQ | Antarctica
AG | Antigua and Barbuda
AR | Argentina
AM | Armenia
AW | Aruba
AU | Australia
AT | Austria
AZ | Azerbaijan
BS | Bahamas
BH | Bahrain
BD | Bangladesh
BB | Barbados
BY | Belarus
BE | Belgium
BZ | Belize
BJ | Benin
BM | Bermuda
BT | Bhutan
BO | Bolivia, Plurinational State of
BQ | Bonaire, Sint Eustatius and Saba
BA | Bosnia and Herzegovina
BW | Botswana
BV | Bouvet Island
BR | Brazil
IO | British Indian Ocean Territory
BN | Brunei Darussalam
BG | Bulgaria
BF | Burkina Faso
BI | Burundi
KH | Cambodia
CM | Cameroon
CA | Canada
CV | Cape Verde
KY | Cayman Islands
CF | Central African Republic
TD | Chad
CL | Chile
CN | China
CX | Christmas Island
CC | Cocos (Keeling) Islands
CO | Colombia
KM | Comoros
CG | Congo
CD | Congo, the Democratic Republic of the
CK | Cook Islands
CR | Costa Rica
CI | Côte d'Ivoire
HR | Croatia
CU | Cuba
CW | Curaçao
CY | Cyprus
CZ | Czech Republic
DK | Denmark
DJ | Djibouti
DM | Dominica
DO | Dominican Republic
EC | Ecuador
EG | Egypt
SV | El Salvador
GQ | Equatorial Guinea
ER | Eritrea
EE | Estonia
ET | Ethiopia
FK | Falkland Islands (Malvinas)
FO | Faroe Islands
FJ | Fiji
FI | Finland
FR | France
GF | French Guiana
PF | French Polynesia
TF | French Southern Territories
GA | Gabon
GM | Gambia
GE | Georgia
DE | Germany
GH | Ghana
GI | Gibraltar
GR | Greece
GL | Greenland
GD | Grenada
GP | Guadeloupe
GU | Guam
GT | Guatemala
GG | Guernsey
GN | Guinea
GW | Guinea-Bissau
GY | Guyana
HT | Haiti
HM | Heard Island and McDonald Islands
VA | Holy See (Vatican City State)
HN | Honduras
HK | Hong Kong
HU | Hungary
IS | Iceland
IN | India
ID | Indonesia
IR | Iran, Islamic Republic of
IQ | Iraq
IE | Ireland
IM | Isle of Man
IL | Israel
IT | Italy
JM | Jamaica
JP | Japan
JE | Jersey
JO | Jordan
KZ | Kazakhstan
KE | Kenya
KI | Kiribati
KP | Korea, Democratic People's Republic of
KR | Korea, Republic of
KW | Kuwait
KG | Kyrgyzstan
LA | Lao People's Democratic Republic
LV | Latvia
LB | Lebanon
LS | Lesotho
LR | Liberia
LY | Libya
LI | Liechtenstein
LT | Lithuania
LU | Luxembourg
MO | Macao
MK | Macedonia, the former Yugoslav Republic of
MG | Madagascar
MW | Malawi
MY | Malaysia
MV | Maldives
ML | Mali
MT | Malta
MH | Marshall Islands
MQ | Martinique
MR | Mauritania
MU | Mauritius
YT | Mayotte
MX | Mexico
FM | Micronesia, Federated States of
MD | Moldova, Republic of
MC | Monaco
MN | Mongolia
ME | Montenegro
MS | Montserrat
MA | Morocco
MZ | Mozambique
MM | Myanmar
NA | Namibia
NR | Nauru
NP | Nepal
NL | Netherlands
NC | New Caledonia
NZ | New Zealand
NI | Nicaragua
NE | Niger
NG | Nigeria
NU | Niue
NF | Norfolk Island
MP | Northern Mariana Islands
NO | Norway
OM | Oman
PK | Pakistan
PW | Palau
PS | Palestine, State of
PA | Panama
PG | Papua New Guinea
PY | Paraguay
PE | Peru
PH | Philippines
PN | Pitcairn
PL | Poland
PT | Portugal
PR | Puerto Rico
QA | Qatar
RE | Réunion
RO | Romania
RU | Russian Federation
RW | Rwanda
BL | Saint Barthélemy
SH | Saint Helena, Ascension and Tristan da Cunha
KN | Saint Kitts and Nevis
LC | Saint Lucia
MF | Saint Martin (French part)
PM | Saint Pierre and Miquelon
VC | Saint Vincent and the Grenadines
WS | Samoa
SM | San Marino
ST | Sao Tome and Principe
SA | Saudi Arabia
SN | Senegal
RS | Serbia
SC | Seychelles
SL | Sierra Leone
SG | Singapore
SX | Sint Maarten (Dutch part)
SK | Slovakia
SI | Slovenia
SB | Solomon Islands
SO | Somalia
ZA | South Africa
GS | South Georgia and the South Sandwich Islands
SS | South Sudan
ES | Spain
LK | Sri Lanka
SD | Sudan
SR | Suriname
SJ | Svalbard and Jan Mayen
SZ | Swaziland
SE | Sweden
CH | Switzerland
SY | Syrian Arab Republic
TW | Taiwan, Province of China
TJ | Tajikistan
TZ | Tanzania, United Republic of
TH | Thailand
TL | Timor-Leste
TG | Togo
TK | Tokelau
TO | Tonga
TT | Trinidad and Tobago
TN | Tunisia
TR | Turkey
TM | Turkmenistan
TC | Turks and Caicos Islands
TV | Tuvalu
UG | Uganda
UA | Ukraine
AE | United Arab Emirates
GB | United Kingdom
US | United States
UM | United States Minor Outlying Islands
UY | Uruguay
UZ | Uzbekistan
VU | Vanuatu
VE | Venezuela, Bolivarian Republic of
VN | Viet Nam
VG | Virgin Islands, British
VI | Virgin Islands, U.S.
WF | Wallis and Futuna
EH | Western Sahara
YE | Yemen
ZM | Zambia
ZW | Zimbabwe

@Wintereise

This comment has been minimized.

Copy link

commented Jan 25, 2015

Thank you for this.

@4Giedrius

This comment has been minimized.

Copy link

commented Feb 19, 2015

It should be Vietnam instead of Viet Nam

@mekrita

This comment has been minimized.

Copy link

commented Feb 25, 2015

Thank you.

@fredbradley

This comment has been minimized.

Copy link

commented Mar 16, 2015

Thank you! Such a handy thing to save! Exactly what GIST should be used for!

@jakub-dvoracek

This comment has been minimized.

Copy link

commented Mar 18, 2015

thanks ;)

@RamiCanFly

This comment has been minimized.

Copy link

commented Apr 2, 2015

Much appreciated

@afestein

This comment has been minimized.

Copy link

commented Apr 15, 2015

Updated

return array(
    'AF' => 'Afghanistan',
    'AX' => 'Aland Islands',
    'AL' => 'Albania',
    'DZ' => 'Algeria',
    'AS' => 'American Samoa',
    'AD' => 'Andorra',
    'AO' => 'Angola',
    'AI' => 'Anguilla',
    'AQ' => 'Antarctica',
    'AG' => 'Antigua and Barbuda',
    'AR' => 'Argentina',
    'AM' => 'Armenia',
    'AW' => 'Aruba',
    'AU' => 'Australia',
    'AT' => 'Austria',
    'AZ' => 'Azerbaijan',
    'BS' => 'Bahamas',
    'BH' => 'Bahrain',
    'BD' => 'Bangladesh',
    'BB' => 'Barbados',
    'BY' => 'Belarus',
    'BE' => 'Belgium',
    'BZ' => 'Belize',
    'BJ' => 'Benin',
    'BM' => 'Bermuda',
    'BT' => 'Bhutan',
    'BO' => 'Bolivia',
    'BQ' => 'Bonaire, Saint Eustatius and Saba',
    'BA' => 'Bosnia and Herzegovina',
    'BW' => 'Botswana',
    'BV' => 'Bouvet Island',
    'BR' => 'Brazil',
    'IO' => 'British Indian Ocean Territory',
    'VG' => 'British Virgin Islands',
    'BN' => 'Brunei',
    'BG' => 'Bulgaria',
    'BF' => 'Burkina Faso',
    'BI' => 'Burundi',
    'KH' => 'Cambodia',
    'CM' => 'Cameroon',
    'CA' => 'Canada',
    'CV' => 'Cape Verde',
    'KY' => 'Cayman Islands',
    'CF' => 'Central African Republic',
    'TD' => 'Chad',
    'CL' => 'Chile',
    'CN' => 'China',
    'CX' => 'Christmas Island',
    'CC' => 'Cocos Islands',
    'CO' => 'Colombia',
    'KM' => 'Comoros',
    'CK' => 'Cook Islands',
    'CR' => 'Costa Rica',
    'HR' => 'Croatia',
    'CU' => 'Cuba',
    'CW' => 'Curacao',
    'CY' => 'Cyprus',
    'CZ' => 'Czech Republic',
    'CD' => 'Democratic Republic of the Congo',
    'DK' => 'Denmark',
    'DJ' => 'Djibouti',
    'DM' => 'Dominica',
    'DO' => 'Dominican Republic',
    'TL' => 'East Timor',
    'EC' => 'Ecuador',
    'EG' => 'Egypt',
    'SV' => 'El Salvador',
    'GQ' => 'Equatorial Guinea',
    'ER' => 'Eritrea',
    'EE' => 'Estonia',
    'ET' => 'Ethiopia',
    'FK' => 'Falkland Islands',
    'FO' => 'Faroe Islands',
    'FJ' => 'Fiji',
    'FI' => 'Finland',
    'FR' => 'France',
    'GF' => 'French Guiana',
    'PF' => 'French Polynesia',
    'TF' => 'French Southern Territories',
    'GA' => 'Gabon',
    'GM' => 'Gambia',
    'GE' => 'Georgia',
    'DE' => 'Germany',
    'GH' => 'Ghana',
    'GI' => 'Gibraltar',
    'GR' => 'Greece',
    'GL' => 'Greenland',
    'GD' => 'Grenada',
    'GP' => 'Guadeloupe',
    'GU' => 'Guam',
    'GT' => 'Guatemala',
    'GG' => 'Guernsey',
    'GN' => 'Guinea',
    'GW' => 'Guinea-Bissau',
    'GY' => 'Guyana',
    'HT' => 'Haiti',
    'HM' => 'Heard Island and McDonald Islands',
    'HN' => 'Honduras',
    'HK' => 'Hong Kong',
    'HU' => 'Hungary',
    'IS' => 'Iceland',
    'IN' => 'India',
    'ID' => 'Indonesia',
    'IR' => 'Iran',
    'IQ' => 'Iraq',
    'IE' => 'Ireland',
    'IM' => 'Isle of Man',
    'IL' => 'Israel',
    'IT' => 'Italy',
    'CI' => 'Ivory Coast',
    'JM' => 'Jamaica',
    'JP' => 'Japan',
    'JE' => 'Jersey',
    'JO' => 'Jordan',
    'KZ' => 'Kazakhstan',
    'KE' => 'Kenya',
    'KI' => 'Kiribati',
    'XK' => 'Kosovo',
    'KW' => 'Kuwait',
    'KG' => 'Kyrgyzstan',
    'LA' => 'Laos',
    'LV' => 'Latvia',
    'LB' => 'Lebanon',
    'LS' => 'Lesotho',
    'LR' => 'Liberia',
    'LY' => 'Libya',
    'LI' => 'Liechtenstein',
    'LT' => 'Lithuania',
    'LU' => 'Luxembourg',
    'MO' => 'Macao',
    'MK' => 'Macedonia',
    'MG' => 'Madagascar',
    'MW' => 'Malawi',
    'MY' => 'Malaysia',
    'MV' => 'Maldives',
    'ML' => 'Mali',
    'MT' => 'Malta',
    'MH' => 'Marshall Islands',
    'MQ' => 'Martinique',
    'MR' => 'Mauritania',
    'MU' => 'Mauritius',
    'YT' => 'Mayotte',
    'MX' => 'Mexico',
    'FM' => 'Micronesia',
    'MD' => 'Moldova',
    'MC' => 'Monaco',
    'MN' => 'Mongolia',
    'ME' => 'Montenegro',
    'MS' => 'Montserrat',
    'MA' => 'Morocco',
    'MZ' => 'Mozambique',
    'MM' => 'Myanmar',
    'NA' => 'Namibia',
    'NR' => 'Nauru',
    'NP' => 'Nepal',
    'NL' => 'Netherlands',
    'NC' => 'New Caledonia',
    'NZ' => 'New Zealand',
    'NI' => 'Nicaragua',
    'NE' => 'Niger',
    'NG' => 'Nigeria',
    'NU' => 'Niue',
    'NF' => 'Norfolk Island',
    'KP' => 'North Korea',
    'MP' => 'Northern Mariana Islands',
    'NO' => 'Norway',
    'OM' => 'Oman',
    'PK' => 'Pakistan',
    'PW' => 'Palau',
    'PS' => 'Palestinian Territory',
    'PA' => 'Panama',
    'PG' => 'Papua New Guinea',
    'PY' => 'Paraguay',
    'PE' => 'Peru',
    'PH' => 'Philippines',
    'PN' => 'Pitcairn',
    'PL' => 'Poland',
    'PT' => 'Portugal',
    'PR' => 'Puerto Rico',
    'QA' => 'Qatar',
    'CG' => 'Republic of the Congo',
    'RE' => 'Reunion',
    'RO' => 'Romania',
    'RU' => 'Russia',
    'RW' => 'Rwanda',
    'BL' => 'Saint Barthelemy',
    'SH' => 'Saint Helena',
    'KN' => 'Saint Kitts and Nevis',
    'LC' => 'Saint Lucia',
    'MF' => 'Saint Martin',
    'PM' => 'Saint Pierre and Miquelon',
    'VC' => 'Saint Vincent and the Grenadines',
    'WS' => 'Samoa',
    'SM' => 'San Marino',
    'ST' => 'Sao Tome and Principe',
    'SA' => 'Saudi Arabia',
    'SN' => 'Senegal',
    'RS' => 'Serbia',
    'SC' => 'Seychelles',
    'SL' => 'Sierra Leone',
    'SG' => 'Singapore',
    'SX' => 'Sint Maarten',
    'SK' => 'Slovakia',
    'SI' => 'Slovenia',
    'SB' => 'Solomon Islands',
    'SO' => 'Somalia',
    'ZA' => 'South Africa',
    'GS' => 'South Georgia and the South Sandwich Islands',
    'KR' => 'South Korea',
    'SS' => 'South Sudan',
    'ES' => 'Spain',
    'LK' => 'Sri Lanka',
    'SD' => 'Sudan',
    'SR' => 'Suriname',
    'SJ' => 'Svalbard and Jan Mayen',
    'SZ' => 'Swaziland',
    'SE' => 'Sweden',
    'CH' => 'Switzerland',
    'SY' => 'Syria',
    'TW' => 'Taiwan',
    'TJ' => 'Tajikistan',
    'TZ' => 'Tanzania',
    'TH' => 'Thailand',
    'TG' => 'Togo',
    'TK' => 'Tokelau',
    'TO' => 'Tonga',
    'TT' => 'Trinidad and Tobago',
    'TN' => 'Tunisia',
    'TR' => 'Turkey',
    'TM' => 'Turkmenistan',
    'TC' => 'Turks and Caicos Islands',
    'TV' => 'Tuvalu',
    'VI' => 'U.S. Virgin Islands',
    'UG' => 'Uganda',
    'UA' => 'Ukraine',
    'AE' => 'United Arab Emirates',
    'GB' => 'United Kingdom',
    'US' => 'United States',
    'UM' => 'United States Minor Outlying Islands',
    'UY' => 'Uruguay',
    'UZ' => 'Uzbekistan',
    'VU' => 'Vanuatu',
    'VA' => 'Vatican',
    'VE' => 'Venezuela',
    'VN' => 'Vietnam',
    'WF' => 'Wallis and Futuna',
    'EH' => 'Western Sahara',
    'YE' => 'Yemen',
    'ZM' => 'Zambia',
    'ZW' => 'Zimbabwe',
);
?>
@attozk

This comment has been minimized.

Copy link

commented Jun 5, 2015

Thanks!

@dompz

This comment has been minimized.

Copy link

commented Jun 26, 2015

You're a legend! Thanks :-)

@wawbz

This comment has been minimized.

Copy link

commented Aug 12, 2015

Thanks

@muratbeser

This comment has been minimized.

Copy link

commented Aug 12, 2015

http://country.io/data/ can be used also

@ravishakya

This comment has been minimized.

Copy link

commented Oct 14, 2015

Thanks

@LukeXF

This comment has been minimized.

Copy link

commented Nov 26, 2015

Very useful! Thanks man

@codiiv

This comment has been minimized.

Copy link

commented Dec 1, 2015

The Internet is a wonderf Republic!

@nimasdj

This comment has been minimized.

Copy link

commented Dec 10, 2015

@afestein What is the difference of your array with the original post? What are your corrections?

@nimasdj

This comment has been minimized.

Copy link

commented Dec 10, 2015

@miromana What is the difference of your list with the original post? What are your corrections?

@nimasdj

This comment has been minimized.

Copy link

commented Dec 12, 2015

@afestein your array has a missing: AN Netherlands Antilles.

@tdanielcox

This comment has been minimized.

Copy link

commented Jan 2, 2016

Here is the javascript version:

var countries = [
    { code: 'US', name: 'United States' },
    { code: 'GB', name: 'United Kingdom' },
    { code: 'CA', name: 'Canada' },
    { code: 'AF', name: 'Afghanistan' },
    { code: 'AX', name: 'Aland Islands' },
    { code: 'AL', name: 'Albania' },
    { code: 'DZ', name: 'Algeria' },
    { code: 'AS', name: 'American Samoa' },
    { code: 'AD', name: 'Andorra' },
    { code: 'AO', name: 'Angola' },
    { code: 'AI', name: 'Anguilla' },
    { code: 'AQ', name: 'Antarctica' },
    { code: 'AG', name: 'Antigua And Barbuda' },
    { code: 'AR', name: 'Argentina' },
    { code: 'AM', name: 'Armenia' },
    { code: 'AN', name: 'Netherlands Antilles' },
    { code: 'AW', name: 'Aruba' },
    { code: 'AU', name: 'Australia' },
    { code: 'AT', name: 'Austria' },
    { code: 'AZ', name: 'Azerbaijan' },
    { code: 'BS', name: 'Bahamas' },
    { code: 'BH', name: 'Bahrain' },
    { code: 'BD', name: 'Bangladesh' },
    { code: 'BB', name: 'Barbados' },
    { code: 'BY', name: 'Belarus' },
    { code: 'BE', name: 'Belgium' },
    { code: 'BZ', name: 'Belize' },
    { code: 'BJ', name: 'Benin' },
    { code: 'BM', name: 'Bermuda' },
    { code: 'BT', name: 'Bhutan' },
    { code: 'BO', name: 'Bolivia' },
    { code: 'BA', name: 'Bosnia And Herzegovina' },
    { code: 'BW', name: 'Botswana' },
    { code: 'BV', name: 'Bouvet Island' },
    { code: 'BR', name: 'Brazil' },
    { code: 'IO', name: 'British Indian Ocean Territory' },
    { code: 'BN', name: 'Brunei Darussalam' },
    { code: 'BG', name: 'Bulgaria' },
    { code: 'BF', name: 'Burkina Faso' },
    { code: 'BI', name: 'Burundi' },
    { code: 'KH', name: 'Cambodia' },
    { code: 'CM', name: 'Cameroon' },
    { code: 'CA', name: 'Canada' },
    { code: 'CV', name: 'Cape Verde' },
    { code: 'KY', name: 'Cayman Islands' },
    { code: 'CF', name: 'Central African Republic' },
    { code: 'TD', name: 'Chad' },
    { code: 'CL', name: 'Chile' },
    { code: 'CN', name: 'China' },
    { code: 'CX', name: 'Christmas Island' },
    { code: 'CC', name: 'Cocos (Keeling) Islands' },
    { code: 'CO', name: 'Colombia' },
    { code: 'KM', name: 'Comoros' },
    { code: 'CG', name: 'Congo' },
    { code: 'CD', name: 'Congo, Democratic Republic' },
    { code: 'CK', name: 'Cook Islands' },
    { code: 'CR', name: 'Costa Rica' },
    { code: 'CI', name: 'Cote D\'Ivoire' },
    { code: 'HR', name: 'Croatia' },
    { code: 'CU', name: 'Cuba' },
    { code: 'CY', name: 'Cyprus' },
    { code: 'CZ', name: 'Czech Republic' },
    { code: 'DK', name: 'Denmark' },
    { code: 'DJ', name: 'Djibouti' },
    { code: 'DM', name: 'Dominica' },
    { code: 'DO', name: 'Dominican Republic' },
    { code: 'EC', name: 'Ecuador' },
    { code: 'EG', name: 'Egypt' },
    { code: 'SV', name: 'El Salvador' },
    { code: 'GQ', name: 'Equatorial Guinea' },
    { code: 'ER', name: 'Eritrea' },
    { code: 'EE', name: 'Estonia' },
    { code: 'ET', name: 'Ethiopia' },
    { code: 'FK', name: 'Falkland Islands (Malvinas)' },
    { code: 'FO', name: 'Faroe Islands' },
    { code: 'FJ', name: 'Fiji' },
    { code: 'FI', name: 'Finland' },
    { code: 'FR', name: 'France' },
    { code: 'GF', name: 'French Guiana' },
    { code: 'PF', name: 'French Polynesia' },
    { code: 'TF', name: 'French Southern Territories' },
    { code: 'GA', name: 'Gabon' },
    { code: 'GM', name: 'Gambia' },
    { code: 'GE', name: 'Georgia' },
    { code: 'DE', name: 'Germany' },
    { code: 'GH', name: 'Ghana' },
    { code: 'GI', name: 'Gibraltar' },
    { code: 'GR', name: 'Greece' },
    { code: 'GL', name: 'Greenland' },
    { code: 'GD', name: 'Grenada' },
    { code: 'GP', name: 'Guadeloupe' },
    { code: 'GU', name: 'Guam' },
    { code: 'GT', name: 'Guatemala' },
    { code: 'GG', name: 'Guernsey' },
    { code: 'GN', name: 'Guinea' },
    { code: 'GW', name: 'Guinea-Bissau' },
    { code: 'GY', name: 'Guyana' },
    { code: 'HT', name: 'Haiti' },
    { code: 'HM', name: 'Heard Island & Mcdonald Islands' },
    { code: 'VA', name: 'Holy See (Vatican City State)' },
    { code: 'HN', name: 'Honduras' },
    { code: 'HK', name: 'Hong Kong' },
    { code: 'HU', name: 'Hungary' },
    { code: 'IS', name: 'Iceland' },
    { code: 'IN', name: 'India' },
    { code: 'ID', name: 'Indonesia' },
    { code: 'IR', name: 'Iran, Islamic Republic Of' },
    { code: 'IQ', name: 'Iraq' },
    { code: 'IE', name: 'Ireland' },
    { code: 'IM', name: 'Isle Of Man' },
    { code: 'IL', name: 'Israel' },
    { code: 'IT', name: 'Italy' },
    { code: 'JM', name: 'Jamaica' },
    { code: 'JP', name: 'Japan' },
    { code: 'JE', name: 'Jersey' },
    { code: 'JO', name: 'Jordan' },
    { code: 'KZ', name: 'Kazakhstan' },
    { code: 'KE', name: 'Kenya' },
    { code: 'KI', name: 'Kiribati' },
    { code: 'KR', name: 'Korea' },
    { code: 'KW', name: 'Kuwait' },
    { code: 'KG', name: 'Kyrgyzstan' },
    { code: 'LA', name: 'Lao People\'s Democratic Republic' },
    { code: 'LV', name: 'Latvia' },
    { code: 'LB', name: 'Lebanon' },
    { code: 'LS', name: 'Lesotho' },
    { code: 'LR', name: 'Liberia' },
    { code: 'LY', name: 'Libyan Arab Jamahiriya' },
    { code: 'LI', name: 'Liechtenstein' },
    { code: 'LT', name: 'Lithuania' },
    { code: 'LU', name: 'Luxembourg' },
    { code: 'MO', name: 'Macao' },
    { code: 'MK', name: 'Macedonia' },
    { code: 'MG', name: 'Madagascar' },
    { code: 'MW', name: 'Malawi' },
    { code: 'MY', name: 'Malaysia' },
    { code: 'MV', name: 'Maldives' },
    { code: 'ML', name: 'Mali' },
    { code: 'MT', name: 'Malta' },
    { code: 'MH', name: 'Marshall Islands' },
    { code: 'MQ', name: 'Martinique' },
    { code: 'MR', name: 'Mauritania' },
    { code: 'MU', name: 'Mauritius' },
    { code: 'YT', name: 'Mayotte' },
    { code: 'MX', name: 'Mexico' },
    { code: 'FM', name: 'Micronesia, Federated States Of' },
    { code: 'MD', name: 'Moldova' },
    { code: 'MC', name: 'Monaco' },
    { code: 'MN', name: 'Mongolia' },
    { code: 'ME', name: 'Montenegro' },
    { code: 'MS', name: 'Montserrat' },
    { code: 'MA', name: 'Morocco' },
    { code: 'MZ', name: 'Mozambique' },
    { code: 'MM', name: 'Myanmar' },
    { code: 'NA', name: 'Namibia' },
    { code: 'NR', name: 'Nauru' },
    { code: 'NP', name: 'Nepal' },
    { code: 'NL', name: 'Netherlands' },
    { code: 'AN', name: 'Netherlands Antilles' },
    { code: 'NC', name: 'New Caledonia' },
    { code: 'NZ', name: 'New Zealand' },
    { code: 'NI', name: 'Nicaragua' },
    { code: 'NE', name: 'Niger' },
    { code: 'NG', name: 'Nigeria' },
    { code: 'NU', name: 'Niue' },
    { code: 'NF', name: 'Norfolk Island' },
    { code: 'MP', name: 'Northern Mariana Islands' },
    { code: 'NO', name: 'Norway' },
    { code: 'OM', name: 'Oman' },
    { code: 'PK', name: 'Pakistan' },
    { code: 'PW', name: 'Palau' },
    { code: 'PS', name: 'Palestinian Territory, Occupied' },
    { code: 'PA', name: 'Panama' },
    { code: 'PG', name: 'Papua New Guinea' },
    { code: 'PY', name: 'Paraguay' },
    { code: 'PE', name: 'Peru' },
    { code: 'PH', name: 'Philippines' },
    { code: 'PN', name: 'Pitcairn' },
    { code: 'PL', name: 'Poland' },
    { code: 'PT', name: 'Portugal' },
    { code: 'PR', name: 'Puerto Rico' },
    { code: 'QA', name: 'Qatar' },
    { code: 'RE', name: 'Reunion' },
    { code: 'RO', name: 'Romania' },
    { code: 'RU', name: 'Russian Federation' },
    { code: 'RW', name: 'Rwanda' },
    { code: 'BL', name: 'Saint Barthelemy' },
    { code: 'SH', name: 'Saint Helena' },
    { code: 'KN', name: 'Saint Kitts And Nevis' },
    { code: 'LC', name: 'Saint Lucia' },
    { code: 'MF', name: 'Saint Martin' },
    { code: 'PM', name: 'Saint Pierre And Miquelon' },
    { code: 'VC', name: 'Saint Vincent And Grenadines' },
    { code: 'WS', name: 'Samoa' },
    { code: 'SM', name: 'San Marino' },
    { code: 'ST', name: 'Sao Tome And Principe' },
    { code: 'SA', name: 'Saudi Arabia' },
    { code: 'SN', name: 'Senegal' },
    { code: 'RS', name: 'Serbia' },
    { code: 'SC', name: 'Seychelles' },
    { code: 'SL', name: 'Sierra Leone' },
    { code: 'SG', name: 'Singapore' },
    { code: 'SK', name: 'Slovakia' },
    { code: 'SI', name: 'Slovenia' },
    { code: 'SB', name: 'Solomon Islands' },
    { code: 'SO', name: 'Somalia' },
    { code: 'ZA', name: 'South Africa' },
    { code: 'GS', name: 'South Georgia And Sandwich Isl.' },
    { code: 'ES', name: 'Spain' },
    { code: 'LK', name: 'Sri Lanka' },
    { code: 'SD', name: 'Sudan' },
    { code: 'SR', name: 'Suriname' },
    { code: 'SJ', name: 'Svalbard And Jan Mayen' },
    { code: 'SZ', name: 'Swaziland' },
    { code: 'SE', name: 'Sweden' },
    { code: 'CH', name: 'Switzerland' },
    { code: 'SY', name: 'Syrian Arab Republic' },
    { code: 'TW', name: 'Taiwan' },
    { code: 'TJ', name: 'Tajikistan' },
    { code: 'TZ', name: 'Tanzania' },
    { code: 'TH', name: 'Thailand' },
    { code: 'TL', name: 'Timor-Leste' },
    { code: 'TG', name: 'Togo' },
    { code: 'TK', name: 'Tokelau' },
    { code: 'TO', name: 'Tonga' },
    { code: 'TT', name: 'Trinidad And Tobago' },
    { code: 'TN', name: 'Tunisia' },
    { code: 'TR', name: 'Turkey' },
    { code: 'TM', name: 'Turkmenistan' },
    { code: 'TC', name: 'Turks And Caicos Islands' },
    { code: 'TV', name: 'Tuvalu' },
    { code: 'UG', name: 'Uganda' },
    { code: 'UA', name: 'Ukraine' },
    { code: 'AE', name: 'United Arab Emirates' },
    { code: 'GB', name: 'United Kingdom' },
    { code: 'US', name: 'United States' },
    { code: 'UM', name: 'United States Outlying Islands' },
    { code: 'UY', name: 'Uruguay' },
    { code: 'UZ', name: 'Uzbekistan' },
    { code: 'VU', name: 'Vanuatu' },
    { code: 'VE', name: 'Venezuela' },
    { code: 'VN', name: 'Viet Nam' },
    { code: 'VG', name: 'Virgin Islands, British' },
    { code: 'VI', name: 'Virgin Islands, U.S.' },
    { code: 'WF', name: 'Wallis And Futuna' },
    { code: 'EH', name: 'Western Sahara' },
    { code: 'YE', name: 'Yemen' },
    { code: 'ZM', name: 'Zambia' },
    { code: 'ZW', name: 'Zimbabwe' },
];
@nikhillad

This comment has been minimized.

Copy link

commented Jan 6, 2016

Thanks a lot !! 👍

@mambajoe

This comment has been minimized.

Copy link

commented Jan 6, 2016

thanks very much for all your work, and those that check the result too.

@kesslerdev

This comment has been minimized.

Copy link

commented Jan 13, 2016

Thanks a lot !!

@jdzorz

This comment has been minimized.

Copy link

commented Mar 17, 2016

in case anyone needed it this way:

$countries = array
(
'United States'=> 'United States',
'Afghanistan'=> 'Afghanistan',
'Aland Islands'=> 'Aland Islands',
'Albania'=> 'Albania',
'Algeria'=> 'Algeria',
'American Samoa'=> 'American Samoa',
'Andorra'=> 'Andorra',
'Angola'=> 'Angola',
'Anguilla'=> 'Anguilla',
'Antarctica'=> 'Antarctica',
'Antigua And Barbuda'=> 'Antigua And Barbuda',
'Argentina'=> 'Argentina',
'Armenia'=> 'Armenia',
'Aruba'=> 'Aruba',
'Australia'=> 'Australia',
'Austria'=> 'Austria',
'Azerbaijan'=> 'Azerbaijan',
'Bahamas'=> 'Bahamas',
'Bahrain'=> 'Bahrain',
'Bangladesh'=> 'Bangladesh',
'Barbados'=> 'Barbados',
'Belarus'=> 'Belarus',
'Belgium'=> 'Belgium',
'Belize'=> 'Belize',
'Benin'=> 'Benin',
'Bermuda'=> 'Bermuda',
'Bhutan'=> 'Bhutan',
'Bolivia'=> 'Bolivia',
'Bosnia And Herzegovina'=> 'Bosnia And Herzegovina',
'Botswana'=> 'Botswana',
'Bouvet Island'=> 'Bouvet Island',
'Brazil'=> 'Brazil',
'British Indian Ocean Territory'=> 'British Indian Ocean Territory',
'Brunei Darussalam'=> 'Brunei Darussalam',
'Bulgaria'=> 'Bulgaria',
'Burkina Faso'=> 'Burkina Faso',
'Burundi'=> 'Burundi',
'Cambodia'=> 'Cambodia',
'Cameroon'=> 'Cameroon',
'Canada'=> 'Canada',
'Cape Verde'=> 'Cape Verde',
'Cayman Islands'=> 'Cayman Islands',
'Central African Republic'=> 'Central African Republic',
'Chad'=> 'Chad',
'Chile'=> 'Chile',
'China'=> 'China',
'Christmas Island'=> 'Christmas Island',
'Cocos (Keeling) Islands'=> 'Cocos (Keeling) Islands',
'Colombia'=> 'Colombia',
'Comoros'=> 'Comoros',
'Congo'=> 'Congo',
'Congo Democratic Republic'=> 'Congo, Democratic Republic',
'Cook Islands'=> 'Cook Islands',
'Costa Rica'=> 'Costa Rica',
'Cote D'Ivoire'=> 'Cote D'Ivoire',
'Croatia'=> 'Croatia',
'Cuba'=> 'Cuba',
'Cyprus'=> 'Cyprus',
'Czech Republic'=> 'Czech Republic',
'Denmark'=> 'Denmark',
'Djibouti'=> 'Djibouti',
'Dominica'=> 'Dominica',
'Dominican Republic'=> 'Dominican Republic',
'Ecuador'=> 'Ecuador',
'Egypt'=> 'Egypt',
'El Salvador'=> 'El Salvador',
'Equatorial Guinea'=> 'Equatorial Guinea',
'Eritrea'=> 'Eritrea',
'Estonia'=> 'Estonia',
'Ethiopia'=> 'Ethiopia',
'Falkland Islands (Malvinas)'=> 'Falkland Islands (Malvinas)',
'Faroe Islands'=> 'Faroe Islands',
'Fiji'=> 'Fiji',
'Finland'=> 'Finland',
'France'=> 'France',
'French Guiana'=> 'French Guiana',
'French Polynesia'=> 'French Polynesia',
'French Southern Territories'=> 'French Southern Territories',
'Gabon'=> 'Gabon',
'Gambia'=> 'Gambia',
'Georgia'=> 'Georgia',
'Germany'=> 'Germany',
'Ghana'=> 'Ghana',
'Gibraltar'=> 'Gibraltar',
'Greece'=> 'Greece',
'Greenland'=> 'Greenland',
'Grenada'=> 'Grenada',
'Guadeloupe'=> 'Guadeloupe',
'Guam'=> 'Guam',
'Guatemala'=> 'Guatemala',
'Guernsey'=> 'Guernsey',
'Guinea'=> 'Guinea',
'Guinea-Bissau'=> 'Guinea-Bissau',
'Guyana'=> 'Guyana',
'Haiti'=> 'Haiti',
'Heard Island & Mcdonald Islands'=> 'Heard Island & Mcdonald Islands',
'Holy See (Vatican City State)'=> 'Holy See (Vatican City State)',
'Honduras'=> 'Honduras',
'Hong Kong'=> 'Hong Kong',
'Hungary'=> 'Hungary',
'Iceland'=> 'Iceland',
'India'=> 'India',
'Indonesia'=> 'Indonesia',
'Iran Islamic Republic Of'=> 'Iran, Islamic Republic Of',
'Iraq'=> 'Iraq',
'Ireland'=> 'Ireland',
'Isle Of Man'=> 'Isle Of Man',
'Israel'=> 'Israel',
'Italy'=> 'Italy',
'Jamaica'=> 'Jamaica',
'Japan'=> 'Japan',
'Jersey'=> 'Jersey',
'Jordan'=> 'Jordan',
'Kazakhstan'=> 'Kazakhstan',
'Kenya'=> 'Kenya',
'Kiribati'=> 'Kiribati',
'Korea'=> 'Korea',
'Kuwait'=> 'Kuwait',
'Kyrgyzstan'=> 'Kyrgyzstan',
'Lao People's Democratic Republic'=> 'Lao People's Democratic Republic',
'Latvia'=> 'Latvia',
'Lebanon'=> 'Lebanon',
'Lesotho'=> 'Lesotho',
'Liberia'=> 'Liberia',
'Libyan Arab Jamahiriya'=> 'Libyan Arab Jamahiriya',
'Liechtenstein'=> 'Liechtenstein',
'Lithuania'=> 'Lithuania',
'Luxembourg'=> 'Luxembourg',
'Macao'=> 'Macao',
'Macedonia'=> 'Macedonia',
'Madagascar'=> 'Madagascar',
'Malawi'=> 'Malawi',
'Malaysia'=> 'Malaysia',
'Maldives'=> 'Maldives',
'Mali'=> 'Mali',
'Malta'=> 'Malta',
'Marshall Islands'=> 'Marshall Islands',
'Martinique'=> 'Martinique',
'Mauritania'=> 'Mauritania',
'Mauritius'=> 'Mauritius',
'Mayotte'=> 'Mayotte',
'Mexico'=> 'Mexico',
'Micronesia Federated States Of'=> 'Micronesia, Federated States Of',
'Moldova'=> 'Moldova',
'Monaco'=> 'Monaco',
'Mongolia'=> 'Mongolia',
'Montenegro'=> 'Montenegro',
'Montserrat'=> 'Montserrat',
'Morocco'=> 'Morocco',
'Mozambique'=> 'Mozambique',
'Myanmar'=> 'Myanmar',
'Namibia'=> 'Namibia',
'Nauru'=> 'Nauru',
'Nepal'=> 'Nepal',
'Netherlands'=> 'Netherlands',
'Netherlands Antilles'=> 'Netherlands Antilles',
'New Caledonia'=> 'New Caledonia',
'New Zealand'=> 'New Zealand',
'Nicaragua'=> 'Nicaragua',
'Niger'=> 'Niger',
'Nigeria'=> 'Nigeria',
'Niue'=> 'Niue',
'Norfolk Island'=> 'Norfolk Island',
'Northern Mariana Islands'=> 'Northern Mariana Islands',
'Norway'=> 'Norway',
'Oman'=> 'Oman',
'Pakistan'=> 'Pakistan',
'Palau'=> 'Palau',
'Palestinian Territory Occupied'=> 'Palestinian Territory, Occupied',
'Panama'=> 'Panama',
'Papua New Guinea'=> 'Papua New Guinea',
'Paraguay'=> 'Paraguay',
'Peru'=> 'Peru',
'Philippines'=> 'Philippines',
'Pitcairn'=> 'Pitcairn',
'Poland'=> 'Poland',
'Portugal'=> 'Portugal',
'Puerto Rico'=> 'Puerto Rico',
'Qatar'=> 'Qatar',
'Reunion'=> 'Reunion',
'Romania'=> 'Romania',
'Russian Federation'=> 'Russian Federation',
'Rwanda'=> 'Rwanda',
'Saint Barthelemy'=> 'Saint Barthelemy',
'Saint Helena'=> 'Saint Helena',
'Saint Kitts And Nevis'=> 'Saint Kitts And Nevis',
'Saint Lucia'=> 'Saint Lucia',
'Saint Martin'=> 'Saint Martin',
'Saint Pierre And Miquelon'=> 'Saint Pierre And Miquelon',
'Saint Vincent And Grenadines'=> 'Saint Vincent And Grenadines',
'Samoa'=> 'Samoa',
'San Marino'=> 'San Marino',
'Sao Tome And Principe'=> 'Sao Tome And Principe',
'Saudi Arabia'=> 'Saudi Arabia',
'Senegal'=> 'Senegal',
'Serbia'=> 'Serbia',
'Seychelles'=> 'Seychelles',
'Sierra Leone'=> 'Sierra Leone',
'Singapore'=> 'Singapore',
'Slovakia'=> 'Slovakia',
'Slovenia'=> 'Slovenia',
'Solomon Islands'=> 'Solomon Islands',
'Somalia'=> 'Somalia',
'South Africa'=> 'South Africa',
'South Georgia And Sandwich Isl.'=> 'South Georgia And Sandwich Isl.',
'Spain'=> 'Spain',
'Sri Lanka'=> 'Sri Lanka',
'Sudan'=> 'Sudan',
'Suriname'=> 'Suriname',
'Svalbard And Jan Mayen'=> 'Svalbard And Jan Mayen',
'Swaziland'=> 'Swaziland',
'Sweden'=> 'Sweden',
'Switzerland'=> 'Switzerland',
'Syrian Arab Republic'=> 'Syrian Arab Republic',
'Taiwan'=> 'Taiwan',
'Tajikistan'=> 'Tajikistan',
'Tanzania'=> 'Tanzania',
'Thailand'=> 'Thailand',
'Timor-Leste'=> 'Timor-Leste',
'Togo'=> 'Togo',
'Tokelau'=> 'Tokelau',
'Tonga'=> 'Tonga',
'Trinidad And Tobago'=> 'Trinidad And Tobago',
'Tunisia'=> 'Tunisia',
'Turkey'=> 'Turkey',
'Turkmenistan'=> 'Turkmenistan',
'Turks And Caicos Islands'=> 'Turks And Caicos Islands',
'Tuvalu'=> 'Tuvalu',
'Uganda'=> 'Uganda',
'Ukraine'=> 'Ukraine',
'United Arab Emirates'=> 'United Arab Emirates',
'United Kingdom'=> 'United Kingdom',
'United States Outlying Islands'=> 'United States Outlying Islands',
'Uruguay'=> 'Uruguay',
'Uzbekistan'=> 'Uzbekistan',
'Vanuatu'=> 'Vanuatu',
'Venezuela'=> 'Venezuela',
'Viet Nam'=> 'Viet Nam',
'Virgin Islands British'=> 'Virgin Islands, British',
'Virgin Islands U.S.'=> 'Virgin Islands, U.S.',
'Wallis And Futuna'=> 'Wallis And Futuna',
'Western Sahara'=> 'Western Sahara',
'Yemen'=> 'Yemen',
'Zambia'=> 'Zambia',
'Zimbabwe'=> 'Zimbabwe',
);

@TaylorFoster90

This comment has been minimized.

Copy link

commented Apr 19, 2016

Great success +1

@alcohol

This comment has been minimized.

Copy link

commented Apr 21, 2016

For anyone interested; I've been maintaining https://github.com/alcohol/iso3166 for quite a while :-)

@azizjassar

This comment has been minimized.

Copy link

commented May 7, 2016

Thank you very much for, it helps me a lot. i appreciate that. keep going man 👍

@salborrelli

This comment has been minimized.

Copy link

commented May 19, 2016

Thank you very much you saved me half a hour of annoying typing and text editing 😄

@EduardMaghakyan

This comment has been minimized.

Copy link

commented May 31, 2016

thanks :)

@david62311

This comment has been minimized.

Copy link

commented Jun 10, 2016

I tried it out and it works similar to the way we have it in or script but, we coded it different but, trying out your code really helped me understand what the problem was with our. There is not supposed to be a comma after Zimbabwe.

We needed a blank at the top our code so, it didn't pre-select the Country. It was easy enough to add this with single quotes above Afghanistan:
'' => '',

Thanks for sharing this! It really was helpful!

@kamililyas

This comment has been minimized.

Copy link

commented Sep 7, 2016

Thanks a lot @vxnick

And also @alcohol 👍

@subssubs

This comment has been minimized.

Copy link

commented Sep 29, 2016

Maybe a bit off topic of the code iteslf- but I might suggest that anybody actually using this code is that they need to check the content against heir requirements.

Pitcairn, Tuvalu, and Bouvet Island?

You need "the list of all countries,"- ok. But probably you don't. Do your business and your customers a favor, think for a minute about whether you really need all the countries on the list.

Cheers.

@alfaq

This comment has been minimized.

Copy link

commented Nov 2, 2016

Here you can get array 2code to 3 code
example: "AF" => "AFG",
https://github.com/alfaq/country2alphawith3alpha/blob/master/countries.php

@alexetgus

This comment has been minimized.

Copy link

commented Nov 14, 2016

Great! Thank you very much! 👍

@ghaydarov

This comment has been minimized.

Copy link

commented Feb 3, 2017

thanks!

@hermandinho

This comment has been minimized.

Copy link

commented Mar 30, 2017

💯

@Zeryther

This comment has been minimized.

Copy link

commented May 7, 2017

Oh my god you saved me so much time. Thank you for sharing this!

@lingtalfi

This comment has been minimized.

Copy link

commented Jun 4, 2017

Thanks

@pikl-cz

This comment has been minimized.

Copy link

commented Jun 21, 2017

Thanks a lot

@alexandergottlieb

This comment has been minimized.

Copy link

commented Jun 25, 2017

Thank you ❤️

@NoahCristino

This comment has been minimized.

Copy link

commented Jul 7, 2017

Thanks!

@alihammad-gist

This comment has been minimized.

Copy link

commented Jul 12, 2017

Thank you

@mugagambi

This comment has been minimized.

Copy link

commented Jan 25, 2018

Thanks a lot

@kachna96

This comment has been minimized.

Copy link

commented Feb 10, 2018

Thanks!

@iamdual

This comment has been minimized.

Copy link

commented Mar 1, 2018

Also, here is the inline version:

$countries = array('AF' => 'Afghanistan', 'AX' => 'Aland Islands', 'AL' => 'Albania', 'DZ' => 'Algeria', 'AS' => 'American Samoa', 'AD' => 'Andorra', 'AO' => 'Angola', 'AI' => 'Anguilla', 'AQ' => 'Antarctica', 'AG' => 'Antigua And Barbuda', 'AR' => 'Argentina', 'AM' => 'Armenia', 'AW' => 'Aruba', 'AU' => 'Australia', 'AT' => 'Austria', 'AZ' => 'Azerbaijan', 'BS' => 'Bahamas', 'BH' => 'Bahrain', 'BD' => 'Bangladesh', 'BB' => 'Barbados', 'BY' => 'Belarus', 'BE' => 'Belgium', 'BZ' => 'Belize', 'BJ' => 'Benin', 'BM' => 'Bermuda', 'BT' => 'Bhutan', 'BO' => 'Bolivia', 'BA' => 'Bosnia And Herzegovina', 'BW' => 'Botswana', 'BV' => 'Bouvet Island', 'BR' => 'Brazil', 'IO' => 'British Indian Ocean Territory', 'BN' => 'Brunei Darussalam', 'BG' => 'Bulgaria', 'BF' => 'Burkina Faso', 'BI' => 'Burundi', 'KH' => 'Cambodia', 'CM' => 'Cameroon', 'CA' => 'Canada', 'CV' => 'Cape Verde', 'KY' => 'Cayman Islands', 'CF' => 'Central African Republic', 'TD' => 'Chad', 'CL' => 'Chile', 'CN' => 'China', 'CX' => 'Christmas Island', 'CC' => 'Cocos (Keeling) Islands', 'CO' => 'Colombia', 'KM' => 'Comoros', 'CG' => 'Congo', 'CD' => 'Congo, Democratic Republic', 'CK' => 'Cook Islands', 'CR' => 'Costa Rica', 'CI' => 'Cote D\'Ivoire', 'HR' => 'Croatia', 'CU' => 'Cuba', 'CY' => 'Cyprus', 'CZ' => 'Czech Republic', 'DK' => 'Denmark', 'DJ' => 'Djibouti', 'DM' => 'Dominica', 'DO' => 'Dominican Republic', 'EC' => 'Ecuador', 'EG' => 'Egypt', 'SV' => 'El Salvador', 'GQ' => 'Equatorial Guinea', 'ER' => 'Eritrea', 'EE' => 'Estonia', 'ET' => 'Ethiopia', 'FK' => 'Falkland Islands (Malvinas)', 'FO' => 'Faroe Islands', 'FJ' => 'Fiji', 'FI' => 'Finland', 'FR' => 'France', 'GF' => 'French Guiana', 'PF' => 'French Polynesia', 'TF' => 'French Southern Territories', 'GA' => 'Gabon', 'GM' => 'Gambia', 'GE' => 'Georgia', 'DE' => 'Germany', 'GH' => 'Ghana', 'GI' => 'Gibraltar', 'GR' => 'Greece', 'GL' => 'Greenland', 'GD' => 'Grenada', 'GP' => 'Guadeloupe', 'GU' => 'Guam', 'GT' => 'Guatemala', 'GG' => 'Guernsey', 'GN' => 'Guinea', 'GW' => 'Guinea-Bissau', 'GY' => 'Guyana', 'HT' => 'Haiti', 'HM' => 'Heard Island & Mcdonald Islands', 'VA' => 'Holy See (Vatican City State)', 'HN' => 'Honduras', 'HK' => 'Hong Kong', 'HU' => 'Hungary', 'IS' => 'Iceland', 'IN' => 'India', 'ID' => 'Indonesia', 'IR' => 'Iran, Islamic Republic Of', 'IQ' => 'Iraq', 'IE' => 'Ireland', 'IM' => 'Isle Of Man', 'IL' => 'Israel', 'IT' => 'Italy', 'JM' => 'Jamaica', 'JP' => 'Japan', 'JE' => 'Jersey', 'JO' => 'Jordan', 'KZ' => 'Kazakhstan', 'KE' => 'Kenya', 'KI' => 'Kiribati', 'KR' => 'Korea', 'KW' => 'Kuwait', 'KG' => 'Kyrgyzstan', 'LA' => 'Lao People\'s Democratic Republic', 'LV' => 'Latvia', 'LB' => 'Lebanon', 'LS' => 'Lesotho', 'LR' => 'Liberia', 'LY' => 'Libyan Arab Jamahiriya', 'LI' => 'Liechtenstein', 'LT' => 'Lithuania', 'LU' => 'Luxembourg', 'MO' => 'Macao', 'MK' => 'Macedonia', 'MG' => 'Madagascar', 'MW' => 'Malawi', 'MY' => 'Malaysia', 'MV' => 'Maldives', 'ML' => 'Mali', 'MT' => 'Malta', 'MH' => 'Marshall Islands', 'MQ' => 'Martinique', 'MR' => 'Mauritania', 'MU' => 'Mauritius', 'YT' => 'Mayotte', 'MX' => 'Mexico', 'FM' => 'Micronesia, Federated States Of', 'MD' => 'Moldova', 'MC' => 'Monaco', 'MN' => 'Mongolia', 'ME' => 'Montenegro', 'MS' => 'Montserrat', 'MA' => 'Morocco', 'MZ' => 'Mozambique', 'MM' => 'Myanmar', 'NA' => 'Namibia', 'NR' => 'Nauru', 'NP' => 'Nepal', 'NL' => 'Netherlands', 'AN' => 'Netherlands Antilles', 'NC' => 'New Caledonia', 'NZ' => 'New Zealand', 'NI' => 'Nicaragua', 'NE' => 'Niger', 'NG' => 'Nigeria', 'NU' => 'Niue', 'NF' => 'Norfolk Island', 'MP' => 'Northern Mariana Islands', 'NO' => 'Norway', 'OM' => 'Oman', 'PK' => 'Pakistan', 'PW' => 'Palau', 'PS' => 'Palestinian Territory, Occupied', 'PA' => 'Panama', 'PG' => 'Papua New Guinea', 'PY' => 'Paraguay', 'PE' => 'Peru', 'PH' => 'Philippines', 'PN' => 'Pitcairn', 'PL' => 'Poland', 'PT' => 'Portugal', 'PR' => 'Puerto Rico', 'QA' => 'Qatar', 'RE' => 'Reunion', 'RO' => 'Romania', 'RU' => 'Russian Federation', 'RW' => 'Rwanda', 'BL' => 'Saint Barthelemy', 'SH' => 'Saint Helena', 'KN' => 'Saint Kitts And Nevis', 'LC' => 'Saint Lucia', 'MF' => 'Saint Martin', 'PM' => 'Saint Pierre And Miquelon', 'VC' => 'Saint Vincent And Grenadines', 'WS' => 'Samoa', 'SM' => 'San Marino', 'ST' => 'Sao Tome And Principe', 'SA' => 'Saudi Arabia', 'SN' => 'Senegal', 'RS' => 'Serbia', 'SC' => 'Seychelles', 'SL' => 'Sierra Leone', 'SG' => 'Singapore', 'SK' => 'Slovakia', 'SI' => 'Slovenia', 'SB' => 'Solomon Islands', 'SO' => 'Somalia', 'ZA' => 'South Africa', 'GS' => 'South Georgia And Sandwich Isl.', 'ES' => 'Spain', 'LK' => 'Sri Lanka', 'SD' => 'Sudan', 'SR' => 'Suriname', 'SJ' => 'Svalbard And Jan Mayen', 'SZ' => 'Swaziland', 'SE' => 'Sweden', 'CH' => 'Switzerland', 'SY' => 'Syrian Arab Republic', 'TW' => 'Taiwan', 'TJ' => 'Tajikistan', 'TZ' => 'Tanzania', 'TH' => 'Thailand', 'TL' => 'Timor-Leste', 'TG' => 'Togo', 'TK' => 'Tokelau', 'TO' => 'Tonga', 'TT' => 'Trinidad And Tobago', 'TN' => 'Tunisia', 'TR' => 'Turkey', 'TM' => 'Turkmenistan', 'TC' => 'Turks And Caicos Islands', 'TV' => 'Tuvalu', 'UG' => 'Uganda', 'UA' => 'Ukraine', 'AE' => 'United Arab Emirates', 'GB' => 'United Kingdom', 'US' => 'United States', 'UM' => 'United States Outlying Islands', 'UY' => 'Uruguay', 'UZ' => 'Uzbekistan', 'VU' => 'Vanuatu', 'VE' => 'Venezuela', 'VN' => 'Viet Nam', 'VG' => 'Virgin Islands, British', 'VI' => 'Virgin Islands, U.S.', 'WF' => 'Wallis And Futuna', 'EH' => 'Western Sahara', 'YE' => 'Yemen', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe');
@RastaFaraLV

This comment has been minimized.

Copy link

commented Apr 26, 2018

Russian Translation:

$countries = array
(
'AF' => 'Афганистан',
'AX' => 'Аландские острова',
'AL' => 'Албания',
'DZ' => 'Алжир',
'AS' => 'Американское Самоа',
'AD' => 'Андорра',
'AO' => 'Ангола',
'AI' => 'Ангилья',
'AQ' => 'Антарктида',
'AG' => 'Антигуа и Барбуда',
'AR' => 'Аргентина',
'AM' => 'Армения',
'AW' => 'Аруба',
'AU' => 'Австралия',
'AT' => 'Австрия',
'AZ' => 'Азербайджан',
'BS' => 'Багамские острова',
'BH' => 'Бахрейн',
'BD' => 'Бангладеш',
'BB' => 'Барбадос',
'BY' => 'Беларусь',
'BE' => 'Бельгия',
'BZ' => 'Белиз',
'BJ' => 'Бенин',
'BM' => 'Бермудские острова',
'BT' => 'Бутан',
'BO' => 'Боливия',
'BQ' => 'Бонэйр, Синт-Эстатиус и Саба',
'BA' => 'Босния и Герцеговина',
'BW' => 'Ботсвана',
'BV' => 'Остров Буве',
'BR' => 'Бразилия',
'IO' => 'Британская территория в Индийском океане',
'VG' => 'Британские Виргинские острова',
'BN' => 'Бруней',
'BG' => 'Болгария',
'BF' => 'Буркина-Фасо',
'BI' => 'Бурунди',
'KH' => 'Камбоджа',
'CM' => 'Камерун',
'CA' => 'Канада',
'CV' => 'Кабо-Верде',
'KY' => 'Каймановы острова',
'CF' => 'Центральноафриканская Республика',
'TD' => 'Чад',
'CL' => 'Чили',
'CN' => 'Китай',
'CX' => 'Остров Рождества',
'CC' => 'Кокосовые острова',
'CO' => 'Колумбия',
'KM' => 'Коморы',
'CK' => 'Острова Кука',
'CR' => 'Коста-Рика',
'HR' => 'Хорватия',
'CU' => 'Куба',
'CW' => 'Кюрасао',
'CY' => 'Кипр',
'CZ' => 'Чехия',
'CD' => 'Демократическая Республика Конго',
'DK' => 'Дания',
'DJ' => 'Джибути',
'DM' => 'Доминика',
'DO' => 'Доминиканская Республика',
'TL' => 'Восточный Тимор',
'EC' => 'Эквадор',
'EG' => 'Египет',
'SV' => 'Сальвадор',
'GQ' => 'Экваториальная Гвинея',
'ER' => 'Эритрея',
'EE' => 'Эстония',
'ET' => 'Эфиопия',
'FK' => 'Фолклендские острова',
'FO' => 'Фарерские острова',
'FJ' => 'Фиджи',
'FI' => 'Финляндия',
'FR' => 'Франция',
'GF' => 'Французская Гвиана',
'PF' => 'Французская Полинезия',
'TF' => 'Французские южные территории',
'GA' => 'Габон',
'GM' => 'Гамбия',
'GE' => 'Грузия',
'DE' => 'Германия',
'GH' => 'Гана',
'GI' => 'Гибралтар',
'GR' => 'Греция',
'GL' => 'Гренландия',
'GD' => 'Гренада',
'GP' => 'Гваделупа',
'GU' => 'Гуам',
'GT' => 'Гватемала',
'GG' => 'Гернси',
'GN' => 'Гвинея',
'GW' => 'Гвинея-Бисау',
'GY' => 'Гайана',
'HT' => 'Гаити',
'HM' => 'Остров Херд и острова Макдональд',
'HN' => 'Гондурас',
'HK' => 'Гонконг',
'HU' => 'Венгрия',
'IS' => 'Исландия',
'IN' => 'Индия',
'ID' => 'Индонезия',
'IR' => 'Иран',
'IQ' => 'Ирак',
'IE' => 'Ирландия',
'IM' => 'Остров Мэн',
'IL' => 'Израиль',
'IT' => 'Италия',
'CI' => 'Кот-д`Ивуар',
'JM' => 'Ямайка',
'JP' => 'Япония',
'JE' => 'Джерси',
'JO' => 'Иордания',
'KZ' => 'Казахстан',
'KE' => 'Кения',
'KI' => 'Кирибати',
'XK' => 'Косово',
'KW' => 'Кувейт',
'KG' => 'Кыргызстан',
'LA' => 'Лаос',
'LV' => 'Латвия',
'LB' => 'Ливан',
'LS' => 'Лесото',
'LR' => 'Либерия',
'LY' => 'Ливия',
'LI' => 'Лихтенштейн',
'LT' => 'Литва',
'LU' => 'Люксембург',
'MO' => 'Макао',
'MK' => 'Македония',
'MG' => 'Мадагаскар',
'MW' => 'Малави',
'MY' => 'Малайзия',
'MV' => 'Мальдивы',
'ML' => 'Мали',
'MT' => 'Мальта',
'MH' => 'Маршалловы Острова',
'MQ' => 'Мартиника',
'MR' => 'Мавритания',
'MU' => 'Маврикий',
'YT' => 'Майотта',
'MX' => 'Мексика',
'FM' => 'Микронезия',
'MD' => 'Молдова',
'MC' => 'Монако',
'MN' => 'Монголия',
'ME' => 'Черногория',
'MS' => 'Монтсеррат',
'MA' => 'Марокко',
'MZ' => 'Мозамбик',
'MM' => 'Мьянма',
'NA' => 'Намибия',
'NR' => 'Науру',
'NP' => 'Непал',
'NL' => 'Нидерланды',
'NC' => 'Новая Каледония',
'NZ' => 'Новая Зеландия',
'NI' => 'Никарагуа',
'NE' => 'Нигер',
'NG' => 'Нигерия',
'NU' => 'Ниуэ',
'NF' => 'Остров Норфолк',
'KP' => 'Северная Корея',
'MP' => 'Северные Марианские острова',
'NO' => 'Норвегия',
'OM' => 'Оман',
'PK' => 'Пакистан',
'PW' => 'Палау',
'PS' => 'Палестинская территория',
'PA' => 'Панама',
'PG' => 'Папуа-Новая Гвинея',
'PY' => 'Парагвай',
'PE' => 'Перу',
'PH' => 'Филиппины',
'PN' => 'Питкэрн',
'PL' => 'Польша',
'PT' => 'Португалия',
'PR' => 'Пуэрто-Рико',
'QA' => 'Катар',
'CG' => 'Республика Конго',
'RE' => 'Реюньон',
'RO' => 'Румыния',
'RU' => 'Россия',
'RW' => 'Руанда',
'BL' => 'Сен-Бартелеми',
'SH' => 'Остров Святой Елены',
'KN' => 'Сент-Китс и Невис',
'LC' => 'Сент-Люсия',
'MF' => 'Сен-Мартен',
'PM' => 'Сен-Пьер и Микелон',
'VC' => 'Сент-Винсент и Гренадины',
'WS' => 'Самоа',
'SM' => 'Сан-Марино',
'ST' => 'Сан-Томе и Принсипи',
'SA' => 'Саудовская Аравия',
'SN' => 'Сенегал',
'RS' => 'Сербия',
'SC' => 'Сейшельские острова',
'SL' => 'Сьерра-Леоне',
'SG' => 'Сингапур',
'SX' => 'Синт-Мартен',
'SK' => 'Словакия',
'SI' => 'Словения',
'SB' => 'Соломоновы Острова',
'SO' => 'Сомали',
'ZA' => 'Южная Африка',
'GS' => 'Южная Георгия и Южные Сандвичевы острова',
'KR' => 'Южная Корея',
'SS' => 'Южный Судан',
'ES' => 'Испания',
'LK' => 'Шри-Ланка',
'SD' => 'Судан',
'SR' => 'Суринам',
'SJ' => 'Шпицберген и Ян-Майен',
'SZ' => 'Свазиленд',
'SE' => 'Швеция',
'CH' => 'Швейцария',
'SY' => 'Сирия',
'TW' => 'Тайвань',
'TJ' => 'Таджикистан',
'TZ' => 'Танзания',
'TH' => 'Таиланд',
'TG' => 'Того',
'TK' => 'Токелау',
'TO' => 'Тонга',
'TT' => 'Тринидад и Тобаго',
'TN' => 'Тунис',
'TR' => 'Турция',
'TM' => 'Туркменистан',
'TC' => 'Острова Теркс и Кайкос',
'TV' => 'Тувалу',
'VI' => 'США. Виргинские острова',
'UG' => 'Уганда',
'UA' => 'Украина',
'AE' => 'Объединенные Арабские Эмираты',
'GB' => 'Великобритания',
'US' => 'США',
'UM' => 'Внешние малые острова США',
'UY' => 'Уругвай',
'UZ' => 'Узбекистан',
'VU' => 'Вануату',
'VA' => 'Ватикан',
'VE' => 'Венесуэла',
'VN' => 'Вьетнам',
'WF' => 'Уоллис и Футуна',
'EH' => 'Западная Сахара',
'YE' => 'Йемен',
'ZM' => 'Замбия',
'ZW' => 'Зимбабве'
);

@vtdoan

This comment has been minimized.

Copy link

commented May 17, 2018

great work! Thank you

@Moniiiiii

This comment has been minimized.

Copy link

commented May 23, 2018

Amazing!

@ilmoralito

This comment has been minimized.

Copy link

commented May 25, 2018

Gracias

@DevTestCRM

This comment has been minimized.

Copy link

commented Jun 6, 2018

fantastic, save a hell of time

@brtsos

This comment has been minimized.

Copy link

commented Nov 4, 2018

Thanks a lot!

@zahirkelloud

This comment has been minimized.

Copy link

commented Dec 19, 2018

country abrev and phone code in javascript

countryCodes = [
	{ 'AD': {'name': 'ANDORRA','code': '376'} },
	{ 'AE': {'name': 'UNITED ARAB EMIRATES','code': '971'} },
	{ 'AF': {'name': 'AFGHANISTAN','code': '93'} },
	{ 'AG': {'name': 'ANTIGUA AND BARBUDA','code': '1268'} },
	{ 'AI': {'name': 'ANGUILLA','code': '1264'} },
	{ 'AL': {'name': 'ALBANIA','code': '355'} },
	{ 'AM': {'name': 'ARMENIA','code': '374'} },
	{ 'AN': {'name': 'NETHERLANDS ANTILLES','code': '599'} },
	{ 'AO': {'name': 'ANGOLA','code': '244'} },
	{ 'AQ': {'name': 'ANTARCTICA','code': '672'} },
	{ 'AR': {'name': 'ARGENTINA','code': '54'} },
	{ 'AS': {'name': 'AMERICAN SAMOA','code': '1684'} },
	{ 'AT': {'name': 'AUSTRIA','code': '43'} },
	{ 'AU': {'name': 'AUSTRALIA','code': '61'} },
	{ 'AW': {'name': 'ARUBA','code': '297'} },
	{ 'AZ': {'name': 'AZERBAIJAN','code': '994'} },
	{ 'BA': {'name': 'BOSNIA AND HERZEGOVINA','code': '387'} },
	{ 'BB': {'name': 'BARBADOS','code': '1246'} },
	{ 'BD': {'name': 'BANGLADESH','code': '880'} },
	{ 'BE': {'name': 'BELGIUM','code': '32'} },
	{ 'BF': {'name': 'BURKINA FASO','code': '226'} },
	{ 'BG': {'name': 'BULGARIA','code': '359'} },
	{ 'BH': {'name': 'BAHRAIN','code': '973'} },
	{ 'BI': {'name': 'BURUNDI','code': '257'} },
	{ 'BJ': {'name': 'BENIN','code': '229'} },
	{ 'BL': {'name': 'SAINT BARTHELEMY','code': '590'} },
	{ 'BM': {'name': 'BERMUDA','code': '1441'} },
	{ 'BN': {'name': 'BRUNEI DARUSSALAM','code': '673'} },
	{ 'BO': {'name': 'BOLIVIA','code': '591'} },
	{ 'BR': {'name': 'BRAZIL','code': '55'} },
	{ 'BS': {'name': 'BAHAMAS','code': '1242'} },
	{ 'BT': {'name': 'BHUTAN','code': '975'} },
	{ 'BW': {'name': 'BOTSWANA','code': '267'} },
	{ 'BY': {'name': 'BELARUS','code': '375'} },
	{ 'BZ': {'name': 'BELIZE','code': '501'} },
	{ 'CA': {'name': 'CANADA','code': '1'} },
	{ 'CC': {'name': 'COCOS (KEELING) ISLANDS','code': '61'} },
	{ 'CD': {'name': 'CONGO, THE DEMOCRATIC REPUBLIC OF THE','code': '243'} },
	{ 'CF': {'name': 'CENTRAL AFRICAN REPUBLIC','code': '236'} },
	{ 'CG': {'name': 'CONGO','code': '242'} },
	{ 'CH': {'name': 'SWITZERLAND','code': '41'} },
	{ 'CI': {'name': 'COTE D IVOIRE','code': '225'} },
	{ 'CK': {'name': 'COOK ISLANDS','code': '682'} },
	{ 'CL': {'name': 'CHILE','code': '56'} },
	{ 'CM': {'name': 'CAMEROON','code': '237'} },
	{ 'CN': {'name': 'CHINA','code': '86'} },
	{ 'CO': {'name': 'COLOMBIA','code': '57'} },
	{ 'CR': {'name': 'COSTA RICA','code': '506'} },
	{ 'CU': {'name': 'CUBA','code': '53'} },
	{ 'CV': {'name': 'CAPE VERDE','code': '238'} },
	{ 'CX': {'name': 'CHRISTMAS ISLAND','code': '61'} },
	{ 'CY': {'name': 'CYPRUS','code': '357'} },
	{ 'CZ': {'name': 'CZECH REPUBLIC','code': '420'} },
	{ 'DE': {'name': 'GERMANY','code': '49'} },
	{ 'DJ': {'name': 'DJIBOUTI','code': '253'} },
	{ 'DK': {'name': 'DENMARK','code': '45'} },
	{ 'DM': {'name': 'DOMINICA','code': '1767'} },
	{ 'DO': {'name': 'DOMINICAN REPUBLIC','code': '1809'} },
	{ 'DZ': {'name': 'ALGERIA','code': '213'} },
	{ 'EC': {'name': 'ECUADOR','code': '593'} },
	{ 'EE': {'name': 'ESTONIA','code': '372'} },
	{ 'EG': {'name': 'EGYPT','code': '20'} },
	{ 'ER': {'name': 'ERITREA','code': '291'} },
	{ 'ES': {'name': 'SPAIN','code': '34'} },
	{ 'ET': {'name': 'ETHIOPIA','code': '251'} },
	{ 'FI': {'name': 'FINLAND','code': '358'} },
	{ 'FJ': {'name': 'FIJI','code': '679'} },
	{ 'FK': {'name': 'FALKLAND ISLANDS (MALVINAS)','code': '500'} },
	{ 'FM': {'name': 'MICRONESIA, FEDERATED STATES OF','code': '691'} },
	{ 'FO': {'name': 'FAROE ISLANDS','code': '298'} },
	{ 'FR': {'name': 'FRANCE','code': '33'} },
	{ 'GA': {'name': 'GABON','code': '241'} },
	{ 'GB': {'name': 'UNITED KINGDOM','code': '44'} },
	{ 'GD': {'name': 'GRENADA','code': '1473'} },
	{ 'GE': {'name': 'GEORGIA','code': '995'} },
	{ 'GH': {'name': 'GHANA','code': '233'} },
	{ 'GI': {'name': 'GIBRALTAR','code': '350'} },
	{ 'GL': {'name': 'GREENLAND','code': '299'} },
	{ 'GM': {'name': 'GAMBIA','code': '220'} },
	{ 'GN': {'name': 'GUINEA','code': '224'} },
	{ 'GQ': {'name': 'EQUATORIAL GUINEA','code': '240'} },
	{ 'GR': {'name': 'GREECE','code': '30'} },
	{ 'GT': {'name': 'GUATEMALA','code': '502'} },
	{ 'GU': {'name': 'GUAM','code': '1671'} },
	{ 'GW': {'name': 'GUINEA-BISSAU','code': '245'} },
	{ 'GY': {'name': 'GUYANA','code': '592'} },
	{ 'HK': {'name': 'HONG KONG','code': '852'} },
	{ 'HN': {'name': 'HONDURAS','code': '504'} },
	{ 'HR': {'name': 'CROATIA','code': '385'} },
	{ 'HT': {'name': 'HAITI','code': '509'} },
	{ 'HU': {'name': 'HUNGARY','code': '36'} },
	{ 'ID': {'name': 'INDONESIA','code': '62'} },
	{ 'IE': {'name': 'IRELAND','code': '353'} },
	{ 'IL': {'name': 'ISRAEL','code': '972'} },
	{ 'IM': {'name': 'ISLE OF MAN','code': '44'} },
	{ 'IN': {'name': 'INDIA','code': '91'} },
	{ 'IQ': {'name': 'IRAQ','code': '964'} },
	{ 'IR': {'name': 'IRAN, ISLAMIC REPUBLIC OF','code': '98'} },
	{ 'IS': {'name': 'ICELAND','code': '354'} },
	{ 'IT': {'name': 'ITALY','code': '39'} },
	{ 'JM': {'name': 'JAMAICA','code': '1876'} },
	{ 'JO': {'name': 'JORDAN','code': '962'} },
	{ 'JP': {'name': 'JAPAN','code': '81'} },
	{ 'KE': {'name': 'KENYA','code': '254'} },
	{ 'KG': {'name': 'KYRGYZSTAN','code': '996'} },
	{ 'KH': {'name': 'CAMBODIA','code': '855'} },
	{ 'KI': {'name': 'KIRIBATI','code': '686'} },
	{ 'KM': {'name': 'COMOROS','code': '269'} },
	{ 'KN': {'name': 'SAINT KITTS AND NEVIS','code': '1869'} },
	{ 'KP': {'name': 'KOREA DEMOCRATIC PEOPLES REPUBLIC OF','code': '850'} },
	{ 'KR': {'name': 'KOREA REPUBLIC OF','code': '82'} },
	{ 'KW': {'name': 'KUWAIT','code': '965'} },
	{ 'KY': {'name': 'CAYMAN ISLANDS','code': '1345'} },
	{ 'KZ': {'name': 'KAZAKSTAN','code': '7'} },
	{ 'LA': {'name': 'LAO PEOPLES DEMOCRATIC REPUBLIC','code': '856'} },
	{ 'LB': {'name': 'LEBANON','code': '961'} },
	{ 'LC': {'name': 'SAINT LUCIA','code': '1758'} },
	{ 'LI': {'name': 'LIECHTENSTEIN','code': '423'} },
	{ 'LK': {'name': 'SRI LANKA','code': '94'} },
	{ 'LR': {'name': 'LIBERIA','code': '231'} },
	{ 'LS': {'name': 'LESOTHO','code': '266'} },
	{ 'LT': {'name': 'LITHUANIA','code': '370'} },
	{ 'LU': {'name': 'LUXEMBOURG','code': '352'} },
	{ 'LV': {'name': 'LATVIA','code': '371'} },
	{ 'LY': {'name': 'LIBYAN ARAB JAMAHIRIYA','code': '218'} },
	{ 'MA': {'name': 'MOROCCO','code': '212'} },
	{ 'MC': {'name': 'MONACO','code': '377'} },
	{ 'MD': {'name': 'MOLDOVA, REPUBLIC OF','code': '373'} },
	{ 'ME': {'name': 'MONTENEGRO','code': '382'} },
	{ 'MF': {'name': 'SAINT MARTIN','code': '1599'} },
	{ 'MG': {'name': 'MADAGASCAR','code': '261'} },
	{ 'MH': {'name': 'MARSHALL ISLANDS','code': '692'} },
	{ 'MK': {'name': 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF','code': '389'} },
	{ 'ML': {'name': 'MALI','code': '223'} },
	{ 'MM': {'name': 'MYANMAR','code': '95'} },
	{ 'MN': {'name': 'MONGOLIA','code': '976'} },
	{ 'MO': {'name': 'MACAU','code': '853'} },
	{ 'MP': {'name': 'NORTHERN MARIANA ISLANDS','code': '1670'} },
	{ 'MR': {'name': 'MAURITANIA','code': '222'} },
	{ 'MS': {'name': 'MONTSERRAT','code': '1664'} },
	{ 'MT': {'name': 'MALTA','code': '356'} },
	{ 'MU': {'name': 'MAURITIUS','code': '230'} },
	{ 'MV': {'name': 'MALDIVES','code': '960'} },
	{ 'MW': {'name': 'MALAWI','code': '265'} },
	{ 'MX': {'name': 'MEXICO','code': '52'} },
	{ 'MY': {'name': 'MALAYSIA','code': '60'} },
	{ 'MZ': {'name': 'MOZAMBIQUE','code': '258'} },
	{ 'NA': {'name': 'NAMIBIA','code': '264'} },
	{ 'NC': {'name': 'NEW CALEDONIA','code': '687'} },
	{ 'NE': {'name': 'NIGER','code': '227'} },
	{ 'NG': {'name': 'NIGERIA','code': '234'} },
	{ 'NI': {'name': 'NICARAGUA','code': '505'} },
	{ 'NL': {'name': 'NETHERLANDS','code': '31'} },
	{ 'NO': {'name': 'NORWAY','code': '47'} },
	{ 'NP': {'name': 'NEPAL','code': '977'} },
	{ 'NR': {'name': 'NAURU','code': '674'} },
	{ 'NU': {'name': 'NIUE','code': '683'} },
	{ 'NZ': {'name': 'NEW ZEALAND','code': '64'} },
	{ 'OM': {'name': 'OMAN','code': '968'} },
	{ 'PA': {'name': 'PANAMA','code': '507'} },
	{ 'PE': {'name': 'PERU','code': '51'} },
	{ 'PF': {'name': 'FRENCH POLYNESIA','code': '689'} },
	{ 'PG': {'name': 'PAPUA NEW GUINEA','code': '675'} },
	{ 'PH': {'name': 'PHILIPPINES','code': '63'} },
	{ 'PK': {'name': 'PAKISTAN','code': '92'} },
	{ 'PL': {'name': 'POLAND','code': '48'} },
	{ 'PM': {'name': 'SAINT PIERRE AND MIQUELON','code': '508'} },
	{ 'PN': {'name': 'PITCAIRN','code': '870'} },
	{ 'PR': {'name': 'PUERTO RICO','code': '1'} },
	{ 'PT': {'name': 'PORTUGAL','code': '351'} },
	{ 'PW': {'name': 'PALAU','code': '680'} },
	{ 'PY': {'name': 'PARAGUAY','code': '595'} },
	{ 'QA': {'name': 'QATAR','code': '974'} },
	{ 'RO': {'name': 'ROMANIA','code': '40'} },
	{ 'RS': {'name': 'SERBIA','code': '381'} },
	{ 'RU': {'name': 'RUSSIAN FEDERATION','code': '7'} },
	{ 'RW': {'name': 'RWANDA','code': '250'} },
	{ 'SA': {'name': 'SAUDI ARABIA','code': '966'} },
	{ 'SB': {'name': 'SOLOMON ISLANDS','code': '677'} },
	{ 'SC': {'name': 'SEYCHELLES','code': '248'} },
	{ 'SD': {'name': 'SUDAN','code': '249'} },
	{ 'SE': {'name': 'SWEDEN','code': '46'} },
	{ 'SG': {'name': 'SINGAPORE','code': '65'} },
	{ 'SH': {'name': 'SAINT HELENA','code': '290'} },
	{ 'SI': {'name': 'SLOVENIA','code': '386'} },
	{ 'SK': {'name': 'SLOVAKIA','code': '421'} },
	{ 'SL': {'name': 'SIERRA LEONE','code': '232'} },
	{ 'SM': {'name': 'SAN MARINO','code': '378'} },
	{ 'SN': {'name': 'SENEGAL','code': '221'} },
	{ 'SO': {'name': 'SOMALIA','code': '252'} },
	{ 'SR': {'name': 'SURINAME','code': '597'} },
	{ 'ST': {'name': 'SAO TOME AND PRINCIPE','code': '239'} },
	{ 'SV': {'name': 'EL SALVADOR','code': '503'} },
	{ 'SY': {'name': 'SYRIAN ARAB REPUBLIC','code': '963'} },
	{ 'SZ': {'name': 'SWAZILAND','code': '268'} },
	{ 'TC': {'name': 'TURKS AND CAICOS ISLANDS','code': '1649'} },
	{ 'TD': {'name': 'CHAD','code': '235'} },
	{ 'TG': {'name': 'TOGO','code': '228'} },
	{ 'TH': {'name': 'THAILAND','code': '66'} },
	{ 'TJ': {'name': 'TAJIKISTAN','code': '992'} },
	{ 'TK': {'name': 'TOKELAU','code': '690'} },
	{ 'TL': {'name': 'TIMOR-LESTE','code': '670'} },
	{ 'TM': {'name': 'TURKMENISTAN','code': '993'} },
	{ 'TN': {'name': 'TUNISIA','code': '216'} },
	{ 'TO': {'name': 'TONGA','code': '676'} },
	{ 'TR': {'name': 'TURKEY','code': '90'} },
	{ 'TT': {'name': 'TRINIDAD AND TOBAGO','code': '1868'} },
	{ 'TV': {'name': 'TUVALU','code': '688'} },
	{ 'TW': {'name': 'TAIWAN, PROVINCE OF CHINA','code': '886'} },
	{ 'TZ': {'name': 'TANZANIA, UNITED REPUBLIC OF','code': '255'} },
	{ 'UA': {'name': 'UKRAINE','code': '380'} },
	{ 'UG': {'name': 'UGANDA','code': '256'} },
	{ 'US': {'name': 'UNITED STATES','code': '1'} },
	{ 'UY': {'name': 'URUGUAY','code': '598'} },
	{ 'UZ': {'name': 'UZBEKISTAN','code': '998'} },
	{ 'VA': {'name': 'HOLY SEE (VATICAN CITY STATE)','code': '39'} },
	{ 'VC': {'name': 'SAINT VINCENT AND THE GRENADINES','code': '1784'} },
	{ 'VE': {'name': 'VENEZUELA','code': '58'} },
	{ 'VG': {'name': 'VIRGIN ISLANDS, BRITISH','code': '1284'} },
	{ 'VI': {'name': 'VIRGIN ISLANDS, U.S.','code': '1340'} },
	{ 'VN': {'name': 'VIET NAM','code': '84'} },
	{ 'VU': {'name': 'VANUATU','code': '678'} },
	{ 'WF': {'name': 'WALLIS AND FUTUNA','code': '681'} },
	{ 'WS': {'name': 'SAMOA','code': '685'} },
	{ 'XK': {'name': 'KOSOVO','code': '381'} },
	{ 'YE': {'name': 'YEMEN','code': '967'} },
	{ 'YT': {'name': 'MAYOTTE','code': '262'} },
	{ 'ZA': {'name': 'SOUTH AFRICA','code': '27'} },
	{ 'ZM': {'name': 'ZAMBIA','code': '260'} },
	{ 'ZW': {'name': 'ZIMBABWE','code': '263'} }
];
@nejib1

This comment has been minimized.

Copy link

commented Jan 10, 2019

function getCountryName($countryCode)
{
    $countries = array('AF' => 'Afghanistan', 'AX' => 'Aland Islands', 'AL' => 'Albania', 'DZ' => 'Algeria', 'AS' => 'American Samoa', 'AD' => 'Andorra', 'AO' => 'Angola', 'AI' => 'Anguilla', 'AQ' => 'Antarctica', 'AG' => 'Antigua And Barbuda', 'AR' => 'Argentina', 'AM' => 'Armenia', 'AW' => 'Aruba', 'AU' => 'Australia', 'AT' => 'Austria', 'AZ' => 'Azerbaijan', 'BS' => 'Bahamas', 'BH' => 'Bahrain', 'BD' => 'Bangladesh', 'BB' => 'Barbados', 'BY' => 'Belarus', 'BE' => 'Belgium', 'BZ' => 'Belize', 'BJ' => 'Benin', 'BM' => 'Bermuda', 'BT' => 'Bhutan', 'BO' => 'Bolivia', 'BA' => 'Bosnia And Herzegovina', 'BW' => 'Botswana', 'BV' => 'Bouvet Island', 'BR' => 'Brazil', 'IO' => 'British Indian Ocean Territory', 'BN' => 'Brunei Darussalam', 'BG' => 'Bulgaria', 'BF' => 'Burkina Faso', 'BI' => 'Burundi', 'KH' => 'Cambodia', 'CM' => 'Cameroon', 'CA' => 'Canada', 'CV' => 'Cape Verde', 'KY' => 'Cayman Islands', 'CF' => 'Central African Republic', 'TD' => 'Chad', 'CL' => 'Chile', 'CN' => 'China', 'CX' => 'Christmas Island', 'CC' => 'Cocos (Keeling) Islands', 'CO' => 'Colombia', 'KM' => 'Comoros', 'CG' => 'Congo', 'CD' => 'Congo, Democratic Republic', 'CK' => 'Cook Islands', 'CR' => 'Costa Rica', 'CI' => 'Cote D\'Ivoire', 'HR' => 'Croatia', 'CU' => 'Cuba', 'CY' => 'Cyprus', 'CZ' => 'Czech Republic', 'DK' => 'Denmark', 'DJ' => 'Djibouti', 'DM' => 'Dominica', 'DO' => 'Dominican Republic', 'EC' => 'Ecuador', 'EG' => 'Egypt', 'SV' => 'El Salvador', 'GQ' => 'Equatorial Guinea', 'ER' => 'Eritrea', 'EE' => 'Estonia', 'ET' => 'Ethiopia', 'FK' => 'Falkland Islands (Malvinas)', 'FO' => 'Faroe Islands', 'FJ' => 'Fiji', 'FI' => 'Finland', 'FR' => 'France', 'GF' => 'French Guiana', 'PF' => 'French Polynesia', 'TF' => 'French Southern Territories', 'GA' => 'Gabon', 'GM' => 'Gambia', 'GE' => 'Georgia', 'DE' => 'Germany', 'GH' => 'Ghana', 'GI' => 'Gibraltar', 'GR' => 'Greece', 'GL' => 'Greenland', 'GD' => 'Grenada', 'GP' => 'Guadeloupe', 'GU' => 'Guam', 'GT' => 'Guatemala', 'GG' => 'Guernsey', 'GN' => 'Guinea', 'GW' => 'Guinea-Bissau', 'GY' => 'Guyana', 'HT' => 'Haiti', 'HM' => 'Heard Island & Mcdonald Islands', 'VA' => 'Holy See (Vatican City State)', 'HN' => 'Honduras', 'HK' => 'Hong Kong', 'HU' => 'Hungary', 'IS' => 'Iceland', 'IN' => 'India', 'ID' => 'Indonesia', 'IR' => 'Iran, Islamic Republic Of', 'IQ' => 'Iraq', 'IE' => 'Ireland', 'IM' => 'Isle Of Man', 'IL' => 'Israel', 'IT' => 'Italy', 'JM' => 'Jamaica', 'JP' => 'Japan', 'JE' => 'Jersey', 'JO' => 'Jordan', 'KZ' => 'Kazakhstan', 'KE' => 'Kenya', 'KI' => 'Kiribati', 'KR' => 'Korea', 'KW' => 'Kuwait', 'KG' => 'Kyrgyzstan', 'LA' => 'Lao People\'s Democratic Republic', 'LV' => 'Latvia', 'LB' => 'Lebanon', 'LS' => 'Lesotho', 'LR' => 'Liberia', 'LY' => 'Libyan Arab Jamahiriya', 'LI' => 'Liechtenstein', 'LT' => 'Lithuania', 'LU' => 'Luxembourg', 'MO' => 'Macao', 'MK' => 'Macedonia', 'MG' => 'Madagascar', 'MW' => 'Malawi', 'MY' => 'Malaysia', 'MV' => 'Maldives', 'ML' => 'Mali', 'MT' => 'Malta', 'MH' => 'Marshall Islands', 'MQ' => 'Martinique', 'MR' => 'Mauritania', 'MU' => 'Mauritius', 'YT' => 'Mayotte', 'MX' => 'Mexico', 'FM' => 'Micronesia, Federated States Of', 'MD' => 'Moldova', 'MC' => 'Monaco', 'MN' => 'Mongolia', 'ME' => 'Montenegro', 'MS' => 'Montserrat', 'MA' => 'Morocco', 'MZ' => 'Mozambique', 'MM' => 'Myanmar', 'NA' => 'Namibia', 'NR' => 'Nauru', 'NP' => 'Nepal', 'NL' => 'Netherlands', 'AN' => 'Netherlands Antilles', 'NC' => 'New Caledonia', 'NZ' => 'New Zealand', 'NI' => 'Nicaragua', 'NE' => 'Niger', 'NG' => 'Nigeria', 'NU' => 'Niue', 'NF' => 'Norfolk Island', 'MP' => 'Northern Mariana Islands', 'NO' => 'Norway', 'OM' => 'Oman', 'PK' => 'Pakistan', 'PW' => 'Palau', 'PS' => 'Palestinian Territory, Occupied', 'PA' => 'Panama', 'PG' => 'Papua New Guinea', 'PY' => 'Paraguay', 'PE' => 'Peru', 'PH' => 'Philippines', 'PN' => 'Pitcairn', 'PL' => 'Poland', 'PT' => 'Portugal', 'PR' => 'Puerto Rico', 'QA' => 'Qatar', 'RE' => 'Reunion', 'RO' => 'Romania', 'RU' => 'Russian Federation', 'RW' => 'Rwanda', 'BL' => 'Saint Barthelemy', 'SH' => 'Saint Helena', 'KN' => 'Saint Kitts And Nevis', 'LC' => 'Saint Lucia', 'MF' => 'Saint Martin', 'PM' => 'Saint Pierre And Miquelon', 'VC' => 'Saint Vincent And Grenadines', 'WS' => 'Samoa', 'SM' => 'San Marino', 'ST' => 'Sao Tome And Principe', 'SA' => 'Saudi Arabia', 'SN' => 'Senegal', 'RS' => 'Serbia', 'SC' => 'Seychelles', 'SL' => 'Sierra Leone', 'SG' => 'Singapore', 'SK' => 'Slovakia', 'SI' => 'Slovenia', 'SB' => 'Solomon Islands', 'SO' => 'Somalia', 'ZA' => 'South Africa', 'GS' => 'South Georgia And Sandwich Isl.', 'ES' => 'Spain', 'LK' => 'Sri Lanka', 'SD' => 'Sudan', 'SR' => 'Suriname', 'SJ' => 'Svalbard And Jan Mayen', 'SZ' => 'Swaziland', 'SE' => 'Sweden', 'CH' => 'Switzerland', 'SY' => 'Syrian Arab Republic', 'TW' => 'Taiwan', 'TJ' => 'Tajikistan', 'TZ' => 'Tanzania', 'TH' => 'Thailand', 'TL' => 'Timor-Leste', 'TG' => 'Togo', 'TK' => 'Tokelau', 'TO' => 'Tonga', 'TT' => 'Trinidad And Tobago', 'TN' => 'Tunisia', 'TR' => 'Turkey', 'TM' => 'Turkmenistan', 'TC' => 'Turks And Caicos Islands', 'TV' => 'Tuvalu', 'UG' => 'Uganda', 'UA' => 'Ukraine', 'AE' => 'United Arab Emirates', 'GB' => 'United Kingdom', 'US' => 'United States', 'UM' => 'United States Outlying Islands', 'UY' => 'Uruguay', 'UZ' => 'Uzbekistan', 'VU' => 'Vanuatu', 'VE' => 'Venezuela', 'VN' => 'Viet Nam', 'VG' => 'Virgin Islands, British', 'VI' => 'Virgin Islands, U.S.', 'WF' => 'Wallis And Futuna', 'EH' => 'Western Sahara', 'YE' => 'Yemen', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe');
    if(isset($countries[$countryCode])) return $countries[$countryCode];
        return "Unknown Country";
}
@wajdijurry

This comment has been minimized.

Copy link

commented Jan 25, 2019

Thanks alot

@Peace-N

This comment has been minimized.

Copy link

commented Feb 1, 2019

Excellent thanks saved me so much time

@jairodmontero

This comment has been minimized.

Copy link

commented Feb 6, 2019

Thank you for this!!!

@taheroo

This comment has been minimized.

Copy link

commented Feb 20, 2019

in case anyone needed it this way :
'Afghanistan' => 'AF',
'Aland Islands' => 'AX',
'Albania' => 'AL',
'Algeria' => 'DZ',
'American Samoa' => 'AS',
'Andorra' => 'AD',
'Angola' => 'AO',
'Anguilla' => 'AI',
'Antarctica' => 'AQ',
'Antigua and Barbuda' => 'AG',
'Argentina' => 'AR',
'Armenia' => 'AM',
'Aruba' => 'AW',
'Australia' => 'AU',
'Austria' => 'AT',
'Azerbaijan' => 'AZ',
'Bahamas' => 'BS',
'Bahrain' => 'BH',
'Bangladesh' => 'BD',
'Barbados' => 'BB',
'Belarus' => 'BY',
'Belgium' => 'BE',
'Belize' => 'BZ',
'Benin' => 'BJ',
'Bermuda' => 'BM',
'Bhutan' => 'BT',
'Bolivia' => 'BO',
'Bonaire, Saint Eustatius and Saba' => 'BQ',
'Bosnia and Herzegovina' => 'BA',
'Botswana' => 'BW',
'Bouvet Island' => 'BV',
'Brazil' => 'BR',
'British Indian Ocean Territory' => 'IO',
'British Virgin Islands' => 'VG',
'Brunei' => 'BN',
'Bulgaria' => 'BG',
'Burkina Faso' => 'BF',
'Burundi' => 'BI',
'Cambodia' => 'KH',
'Cameroon' => 'CM',
'Canada' => 'CA',
'Cape Verde' => 'CV',
'Cayman Islands' => 'KY',
'Central African Republic' => 'CF',
'Chad' => 'TD',
'Chile' => 'CL',
'China' => 'CN',
'Christmas Island' => 'CX',
'Cocos Islands' => 'CC',
'Colombia' => 'CO',
'Comoros' => 'KM',
'Cook Islands' => 'CK',
'Costa Rica' => 'CR',
'Croatia' => 'HR',
'Cuba' => 'CU',
'Curacao' => 'CW',
'Cyprus' => 'CY',
'Czech Republic' => 'CZ',
'Democratic Republic of the Congo' => 'CD',
'Denmark' => 'DK',
'Djibouti' => 'DJ',
'Dominica' => 'DM',
'Dominican Republic' => 'DO',
'East Timor' => 'TL',
'Ecuador' => 'EC',
'Egypt' => 'EG',
'El Salvador' => 'SV',
'Equatorial Guinea' => 'GQ',
'Eritrea' => 'ER',
'Estonia' => 'EE',
'Ethiopia' => 'ET',
'Falkland Islands' => 'FK',
'Faroe Islands' => 'FO',
'Fiji' => 'FJ',
'Finland' => 'FI',
'France' => 'FR',
'French Guiana' => 'GF',
'French Polynesia' => 'PF',
'French Southern Territories' => 'TF',
'Gabon' => 'GA',
'Gambia' => 'GM',
'Georgia' => 'GE',
'Germany' => 'DE',
'Ghana' => 'GH',
'Gibraltar' => 'GI',
'Greece' => 'GR',
'Greenland' => 'GL',
'Grenada' => 'GD',
'Guadeloupe' => 'GP',
'Guam' => 'GU',
'Guatemala' => 'GT',
'Guernsey' => 'GG',
'Guinea' => 'GN',
'Guinea-Bissau' => 'GW',
'Guyana' => 'GY',
'Haiti' => 'HT',
'Heard Island and McDonald Islands' => 'HM',
'Honduras' => 'HN',
'Hong Kong' => 'HK',
'Hungary' => 'HU',
'Iceland' => 'IS',
'India' => 'IN',
'Indonesia' => 'ID',
'Iran' => 'IR',
'Iraq' => 'IQ',
'Ireland' => 'IE',
'Isle of Man' => 'IM',
'Israel' => 'IL',
'Italy' => 'IT',
'Ivory Coast' => 'CI',
'Jamaica' => 'JM',
'Japan' => 'JP',
'Jersey' => 'JE',
'Jordan' => 'JO',
'Kazakhstan' => 'KZ',
'Kenya' => 'KE',
'Kiribati' => 'KI',
'Kosovo' => 'XK',
'Kuwait' => 'KW',
'Kyrgyzstan' => 'KG',
'Laos' => 'LA',
'Latvia' => 'LV',
'Lebanon' => 'LB',
'Lesotho' => 'LS',
'Liberia' => 'LR',
'Libya' => 'LY',
'Liechtenstein' => 'LI',
'Lithuania' => 'LT',
'Luxembourg' => 'LU',
'Macao' => 'MO',
'Macedonia' => 'MK',
'Madagascar' => 'MG',
'Malawi' => 'MW',
'Malaysia' => 'MY',
'Maldives' => 'MV',
'Mali' => 'ML',
'Malta' => 'MT',
'Marshall Islands' => 'MH',
'Martinique' => 'MQ',
'Mauritania' => 'MR',
'Mauritius' => 'MU',
'Mayotte' => 'YT',
'Mexico' => 'MX',
'Micronesia' => 'FM',
'Moldova' => 'MD',
'Monaco' => 'MC',
'Mongolia' => 'MN',
'Montenegro' => 'ME',
'Montserrat' => 'MS',
'Morocco' => 'MA',
'Mozambique' => 'MZ',
'Myanmar' => 'MM',
'Namibia' => 'NA',
'Nauru' => 'NR',
'Nepal' => 'NP',
'Netherlands' => 'NL',
'New Caledonia' => 'NC',
'New Zealand' => 'NZ',
'Nicaragua' => 'NI',
'Niger' => 'NE',
'Nigeria' => 'NG',
'Niue' => 'NU',
'Norfolk Island' => 'NF',
'North Korea' => 'KP',
'Northern Mariana Islands' => 'MP',
'Norway' => 'NO',
'Oman' => 'OM',
'Pakistan' => 'PK',
'Palau' => 'PW',
'Palestinian Territory' => 'PS',
'Panama' => 'PA',
'Papua New Guinea' => 'PG',
'Paraguay' => 'PY',
'Peru' => 'PE',
'Philippines' => 'PH',
'Pitcairn' => 'PN',
'Poland' => 'PL',
'Portugal' => 'PT',
'Puerto Rico' => 'PR',
'Qatar' => 'QA',
'Republic of the Congo' => 'CG',
'Reunion' => 'RE',
'Romania' => 'RO',
'Russia' => 'RU',
'Rwanda' => 'RW',
'Saint Barthelemy' => 'BL',
'Saint Helena' => 'SH',
'Saint Kitts and Nevis' => 'KN',
'Saint Lucia' => 'LC',
'Saint Martin' => 'MF',
'Saint Pierre and Miquelon' => 'PM',
'Saint Vincent and the Grenadines' => 'VC',
'Samoa' => 'WS',
'San Marino' => 'SM',
'Sao Tome and Principe' => 'ST',
'Saudi Arabia' => 'SA',
'Senegal' => 'SN',
'Serbia' => 'RS',
'Seychelles' => 'SC',
'Sierra Leone' => 'SL',
'Singapore' => 'SG',
'Sint Maarten' => 'SX',
'Slovakia' => 'SK',
'Slovenia' => 'SI',
'Solomon Islands' => 'SB',
'Somalia' => 'SO',
'South Africa' => 'ZA',
'South Georgia and the South Sandwich Islands' => 'GS',
'South Korea' => 'KR',
'South Sudan' => 'SS',
'Spain' => 'ES',
'Sri Lanka' => 'LK',
'Sudan' => 'SD',
'Suriname' => 'SR',
'Svalbard and Jan Mayen' => 'SJ',
'Swaziland' => 'SZ',
'Sweden' => 'SE',
'Switzerland' => 'CH',
'Syria' => 'SY',
'Taiwan' => 'TW',
'Tajikistan' => 'TJ',
'Tanzania' => 'TZ',
'Thailand' => 'TH',
'Togo' => 'TG',
'Tokelau' => 'TK',
'Tonga' => 'TO',
'Trinidad and Tobago' => 'TT',
'Tunisia' => 'TN',
'Turkey' => 'TR',
'Turkmenistan' => 'TM',
'Turks and Caicos Islands' => 'TC',
'Tuvalu' => 'TV',
'U.S. Virgin Islands' => 'VI',
'Uganda' => 'UG',
'Ukraine' => 'UA',
'United Arab Emirates' => 'AE',
'United Kingdom' => 'GB',
'United States' => 'US',
'United States Minor Outlying Islands' => 'UM',
'Uruguay' => 'UY',
'Uzbekistan' => 'UZ',
'Vanuatu' => 'VU',
'Vatican' => 'VA',
'Venezuela' => 'VE',
'Vietnam' => 'VN',
'Wallis and Futuna' => 'WF',
'Western Sahara' => 'EH',
'Yemen' => 'YE',
'Zambia' => 'ZM',
'Zimbabwe' => 'ZW',

@azot87137

This comment has been minimized.

Copy link

commented Feb 28, 2019

Thanks

@botaniQQQ

This comment has been minimized.

Copy link

commented Mar 10, 2019

let iso_3166_1 = ['AD','AE','AF','AG','AI','AL','AM','AO','AQ','AR','AS','AT','AU','AW','AX','AZ','BA','BB','BD','BE','BF','BG','BH','BI','BJ','BL','BM','BN','BO','BQ','BR','BS','BT','BV','BW','BY','BZ','CA','CC','CD','CF','CG','CH','CI','CK','CL','CM','CN','CO','CR','CU','CV','CW','CX','CY','CZ','DE','DJ','DK','DM','DO','DZ','EC','EE','EG','EH','ER','ES','ET','FI','FJ','FK','FM','FO','FR','GA','GB','GD','GE','GF','GG','GH','GI','GL','GM','GN','GP','GQ','GR','GS','GT','GU','GW','GY','HK','HM','HN','HR','HT','HU','ID','IE','IL','IM','IN','IO','IQ','IR','IS','IT','JE','JM','JO','JP','KE','KG','KH','KI','KM','KN','KP','KR','KW','KY','KZ','LA','LB','LC','LI','LK','LR','LS','LT','LU','LV','LY','MA','MC','MD','ME','MF','MG','MH','MK','ML','MM','MN','MO','MP','MQ','MR','MS','MT','MU','MV','MW','MX','MY','MZ','NA','NC','NE','NF','NG','NI','NL','NO','NP','NR','NU','NZ','OM','PA','PE','PF','PG','PH','PK','PL','PM','PN','PR','PS','PT','PW','PY','QA','RE','RO','RS','RU','RW','SA','SB','SC','SD','SE','SG','SH','SI','SJ','SK','SL','SM','SN','SO','SR','SS','ST','SV','SX','SY','SZ','TC','TD','TF','TG','TH','TJ','TK','TL','TM','TN','TO','TR','TT','TV','TW','TZ','UA','UG','UM','US','UY','UZ','VA','VC','VE','VG','VI','VN','VU','WF','WS','YE','YT','ZA','ZM','ZW'];

@javanmohamad

This comment has been minimized.

Copy link

commented Mar 15, 2019

Thank you all

@MikaSchmidt

This comment has been minimized.

Copy link

commented Apr 14, 2019

lifesaver!

@McMazalf

This comment has been minimized.

Copy link

commented May 14, 2019

in case anyone needed it this way :
'Afghanistan' => 'AF',
'Aland Islands' => 'AX',
'Albania' => 'AL',
'Algeria' => 'DZ',
'American Samoa' => 'AS',
'Andorra' => 'AD',
'Angola' => 'AO',
'Anguilla' => 'AI',
'Antarctica' => 'AQ',
'Antigua and Barbuda' => 'AG',
'Argentina' => 'AR',
'Armenia' => 'AM',
'Aruba' => 'AW',
'Australia' => 'AU',
'Austria' => 'AT',
'Azerbaijan' => 'AZ',
'Bahamas' => 'BS',
'Bahrain' => 'BH',
'Bangladesh' => 'BD',
'Barbados' => 'BB',
'Belarus' => 'BY',
'Belgium' => 'BE',
'Belize' => 'BZ',
'Benin' => 'BJ',
'Bermuda' => 'BM',
'Bhutan' => 'BT',
'Bolivia' => 'BO',
'Bonaire, Saint Eustatius and Saba' => 'BQ',
'Bosnia and Herzegovina' => 'BA',
'Botswana' => 'BW',
'Bouvet Island' => 'BV',
'Brazil' => 'BR',
'British Indian Ocean Territory' => 'IO',
'British Virgin Islands' => 'VG',
'Brunei' => 'BN',
'Bulgaria' => 'BG',
'Burkina Faso' => 'BF',
'Burundi' => 'BI',
'Cambodia' => 'KH',
'Cameroon' => 'CM',
'Canada' => 'CA',
'Cape Verde' => 'CV',
'Cayman Islands' => 'KY',
'Central African Republic' => 'CF',
'Chad' => 'TD',
'Chile' => 'CL',
'China' => 'CN',
'Christmas Island' => 'CX',
'Cocos Islands' => 'CC',
'Colombia' => 'CO',
'Comoros' => 'KM',
'Cook Islands' => 'CK',
'Costa Rica' => 'CR',
'Croatia' => 'HR',
'Cuba' => 'CU',
'Curacao' => 'CW',
'Cyprus' => 'CY',
'Czech Republic' => 'CZ',
'Democratic Republic of the Congo' => 'CD',
'Denmark' => 'DK',
'Djibouti' => 'DJ',
'Dominica' => 'DM',
'Dominican Republic' => 'DO',
'East Timor' => 'TL',
'Ecuador' => 'EC',
'Egypt' => 'EG',
'El Salvador' => 'SV',
'Equatorial Guinea' => 'GQ',
'Eritrea' => 'ER',
'Estonia' => 'EE',
'Ethiopia' => 'ET',
'Falkland Islands' => 'FK',
'Faroe Islands' => 'FO',
'Fiji' => 'FJ',
'Finland' => 'FI',
'France' => 'FR',
'French Guiana' => 'GF',
'French Polynesia' => 'PF',
'French Southern Territories' => 'TF',
'Gabon' => 'GA',
'Gambia' => 'GM',
'Georgia' => 'GE',
'Germany' => 'DE',
'Ghana' => 'GH',
'Gibraltar' => 'GI',
'Greece' => 'GR',
'Greenland' => 'GL',
'Grenada' => 'GD',
'Guadeloupe' => 'GP',
'Guam' => 'GU',
'Guatemala' => 'GT',
'Guernsey' => 'GG',
'Guinea' => 'GN',
'Guinea-Bissau' => 'GW',
'Guyana' => 'GY',
'Haiti' => 'HT',
'Heard Island and McDonald Islands' => 'HM',
'Honduras' => 'HN',
'Hong Kong' => 'HK',
'Hungary' => 'HU',
'Iceland' => 'IS',
'India' => 'IN',
'Indonesia' => 'ID',
'Iran' => 'IR',
'Iraq' => 'IQ',
'Ireland' => 'IE',
'Isle of Man' => 'IM',
'Israel' => 'IL',
'Italy' => 'IT',
'Ivory Coast' => 'CI',
'Jamaica' => 'JM',
'Japan' => 'JP',
'Jersey' => 'JE',
'Jordan' => 'JO',
'Kazakhstan' => 'KZ',
'Kenya' => 'KE',
'Kiribati' => 'KI',
'Kosovo' => 'XK',
'Kuwait' => 'KW',
'Kyrgyzstan' => 'KG',
'Laos' => 'LA',
'Latvia' => 'LV',
'Lebanon' => 'LB',
'Lesotho' => 'LS',
'Liberia' => 'LR',
'Libya' => 'LY',
'Liechtenstein' => 'LI',
'Lithuania' => 'LT',
'Luxembourg' => 'LU',
'Macao' => 'MO',
'Macedonia' => 'MK',
'Madagascar' => 'MG',
'Malawi' => 'MW',
'Malaysia' => 'MY',
'Maldives' => 'MV',
'Mali' => 'ML',
'Malta' => 'MT',
'Marshall Islands' => 'MH',
'Martinique' => 'MQ',
'Mauritania' => 'MR',
'Mauritius' => 'MU',
'Mayotte' => 'YT',
'Mexico' => 'MX',
'Micronesia' => 'FM',
'Moldova' => 'MD',
'Monaco' => 'MC',
'Mongolia' => 'MN',
'Montenegro' => 'ME',
'Montserrat' => 'MS',
'Morocco' => 'MA',
'Mozambique' => 'MZ',
'Myanmar' => 'MM',
'Namibia' => 'NA',
'Nauru' => 'NR',
'Nepal' => 'NP',
'Netherlands' => 'NL',
'New Caledonia' => 'NC',
'New Zealand' => 'NZ',
'Nicaragua' => 'NI',
'Niger' => 'NE',
'Nigeria' => 'NG',
'Niue' => 'NU',
'Norfolk Island' => 'NF',
'North Korea' => 'KP',
'Northern Mariana Islands' => 'MP',
'Norway' => 'NO',
'Oman' => 'OM',
'Pakistan' => 'PK',
'Palau' => 'PW',
'Palestinian Territory' => 'PS',
'Panama' => 'PA',
'Papua New Guinea' => 'PG',
'Paraguay' => 'PY',
'Peru' => 'PE',
'Philippines' => 'PH',
'Pitcairn' => 'PN',
'Poland' => 'PL',
'Portugal' => 'PT',
'Puerto Rico' => 'PR',
'Qatar' => 'QA',
'Republic of the Congo' => 'CG',
'Reunion' => 'RE',
'Romania' => 'RO',
'Russia' => 'RU',
'Rwanda' => 'RW',
'Saint Barthelemy' => 'BL',
'Saint Helena' => 'SH',
'Saint Kitts and Nevis' => 'KN',
'Saint Lucia' => 'LC',
'Saint Martin' => 'MF',
'Saint Pierre and Miquelon' => 'PM',
'Saint Vincent and the Grenadines' => 'VC',
'Samoa' => 'WS',
'San Marino' => 'SM',
'Sao Tome and Principe' => 'ST',
'Saudi Arabia' => 'SA',
'Senegal' => 'SN',
'Serbia' => 'RS',
'Seychelles' => 'SC',
'Sierra Leone' => 'SL',
'Singapore' => 'SG',
'Sint Maarten' => 'SX',
'Slovakia' => 'SK',
'Slovenia' => 'SI',
'Solomon Islands' => 'SB',
'Somalia' => 'SO',
'South Africa' => 'ZA',
'South Georgia and the South Sandwich Islands' => 'GS',
'South Korea' => 'KR',
'South Sudan' => 'SS',
'Spain' => 'ES',
'Sri Lanka' => 'LK',
'Sudan' => 'SD',
'Suriname' => 'SR',
'Svalbard and Jan Mayen' => 'SJ',
'Swaziland' => 'SZ',
'Sweden' => 'SE',
'Switzerland' => 'CH',
'Syria' => 'SY',
'Taiwan' => 'TW',
'Tajikistan' => 'TJ',
'Tanzania' => 'TZ',
'Thailand' => 'TH',
'Togo' => 'TG',
'Tokelau' => 'TK',
'Tonga' => 'TO',
'Trinidad and Tobago' => 'TT',
'Tunisia' => 'TN',
'Turkey' => 'TR',
'Turkmenistan' => 'TM',
'Turks and Caicos Islands' => 'TC',
'Tuvalu' => 'TV',
'U.S. Virgin Islands' => 'VI',
'Uganda' => 'UG',
'Ukraine' => 'UA',
'United Arab Emirates' => 'AE',
'United Kingdom' => 'GB',
'United States' => 'US',
'United States Minor Outlying Islands' => 'UM',
'Uruguay' => 'UY',
'Uzbekistan' => 'UZ',
'Vanuatu' => 'VU',
'Vatican' => 'VA',
'Venezuela' => 'VE',
'Vietnam' => 'VN',
'Wallis and Futuna' => 'WF',
'Western Sahara' => 'EH',
'Yemen' => 'YE',
'Zambia' => 'ZM',
'Zimbabwe' => 'ZW',

Thank you very much <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.