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',
);
?>
@kachna96
Copy link

kachna96 commented Feb 10, 2018

Thanks!

@iamdual
Copy link

iamdual 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
Copy link

RastaFaraLV 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
Copy link

vtdoan commented May 17, 2018

great work! Thank you

@Moniiiiii
Copy link

Moniiiiii commented May 23, 2018

Amazing!

@ilmoralito
Copy link

ilmoralito commented May 25, 2018

Gracias

@akifsohee
Copy link

akifsohee commented Jun 6, 2018

fantastic, save a hell of time

@brtsos
Copy link

brtsos commented Nov 4, 2018

Thanks a lot!

@zahirkelloud
Copy link

zahirkelloud 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
Copy link

nejib1 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
Copy link

wajdijurry commented Jan 25, 2019

Thanks alot

@Peace-N
Copy link

Peace-N commented Feb 1, 2019

Excellent thanks saved me so much time

@hdmontero
Copy link

hdmontero commented Feb 6, 2019

Thank you for this!!!

@taheroo
Copy link

taheroo 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
Copy link

azot87137 commented Feb 28, 2019

Thanks

@botaniQQQ
Copy link

botaniQQQ 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
Copy link

javanmohamad commented Mar 15, 2019

Thank you all

@MikaSchmidt
Copy link

MikaSchmidt commented Apr 14, 2019

lifesaver!

@McMazalf
Copy link

McMazalf 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

@vanvantsyan
Copy link

vanvantsyan commented Feb 15, 2020

'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',

thankssssssss

@sudarshann
Copy link

sudarshann commented Mar 16, 2020

To render as a select option with a selected country

function get_countries_options($selected_country) {
        
        $options = '';
        $selected = '';
        $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',
        );
        
        foreach ($countries as $code => $country_name) {
           if($selected_country === $code){
                $selected = 'selected="selected"';
                $options .= '<option value="' . $code . '" ' . $selected . ' >'. $country_name . '</option>';
            } else {
                $options .= '<option value="' . $code . '" >'. $country_name . '</option>';
            }
        }
        return $options;

@NanJerry
Copy link

NanJerry commented May 26, 2020

Thanks a lot! This really helps me. Can I copy your code and put it in my codes?

@franolg
Copy link

franolg commented Feb 27, 2021

Thanks a lot bro

@cscottsa
Copy link

cscottsa commented Jul 12, 2021

const countryCodes = [{
    code: "AD",
    name: "ANDORRA"
  }, {
    code: "AE",
    name: "UNITED ARAB EMIRATES"
  }, {
    code: "AF",
    name: "AFGHANISTAN"
  }, {
    code: "AG",
    name: "ANTIGUA AND BARBUDA"
  }, {
    code: "AI",
    name: "ANGUILLA"
  }, {
    code: "AL",
    name: "ALBANIA"
  }, {
    code: "AM",
    name: "ARMENIA"
  }, {
    code: "AN",
    name: "NETHERLANDS ANTILLES"
  }, {
    code: "AO",
    name: "ANGOLA"
  }, {
    code: "AQ",
    name: "ANTARCTICA"
  }, {
    code: "AR",
    name: "ARGENTINA"
  }, {
    code: "AS",
    name: "AMERICAN SAMOA"
  }, {
    code: "AT",
    name: "AUSTRIA"
  }, {
    code: "AU",
    name: "AUSTRALIA"
  }, {
    code: "AW",
    name: "ARUBA"
  }, {
    code: "AZ",
    name: "AZERBAIJAN"
  }, {
    code: "BA",
    name: "BOSNIA AND HERZEGOVINA"
  }, {
    code: "BB",
    name: "BARBADOS"
  }, {
    code: "BD",
    name: "BANGLADESH"
  }, {
    code: "BE",
    name: "BELGIUM"
  }, {
    code: "BF",
    name: "BURKINA FASO"
  }, {
    code: "BG",
    name: "BULGARIA"
  }, {
    code: "BH",
    name: "BAHRAIN"
  }, {
    code: "BI",
    name: "BURUNDI"
  }, {
    code: "BJ",
    name: "BENIN"
  }, {
    code: "BL",
    name: "SAINT BARTHELEMY"
  }, {
    code: "BM",
    name: "BERMUDA"
  }, {
    code: "BN",
    name: "BRUNEI DARUSSALAM"
  }, {
    code: "BO",
    name: "BOLIVIA"
  }, {
    code: "BR",
    name: "BRAZIL"
  }, {
    code: "BS",
    name: "BAHAMAS"
  }, {
    code: "BT",
    name: "BHUTAN"
  }, {
    code: "BW",
    name: "BOTSWANA"
  }, {
    code: "BY",
    name: "BELARUS"
  }, {
    code: "BZ",
    name: "BELIZE"
  }, {
    code: "CA",
    name: "CANADA"
  }, {
    code: "CC",
    name: "COCOS (KEELING) ISLANDS"
  }, {
    code: "CD",
    name: "CONGO, THE DEMOCRATIC REPUBLIC OF THE"
  }, {
    code: "CF",
    name: "CENTRAL AFRICAN REPUBLIC"
  }, {
    code: "CG",
    name: "CONGO"
  }, {
    code: "CH",
    name: "SWITZERLAND"
  }, {
    code: "CI",
    name: "COTE D IVOIRE"
  }, {
    code: "CK",
    name: "COOK ISLANDS"
  }, {
    code: "CL",
    name: "CHILE"
  }, {
    code: "CM",
    name: "CAMEROON"
  }, {
    code: "CN",
    name: "CHINA"
  }, {
    code: "CO",
    name: "COLOMBIA"
  }, {
    code: "CR",
    name: "COSTA RICA"
  }, {
    code: "CU",
    name: "CUBA"
  }, {
    code: "CV",
    name: "CAPE VERDE"
  }, {
    code: "CX",
    name: "CHRISTMAS ISLAND"
  }, {
    code: "CY",
    name: "CYPRUS"
  }, {
    code: "CZ",
    name: "CZECH REPUBLIC"
  }, {
    code: "DE",
    name: "GERMANY"
  }, {
    code: "DJ",
    name: "DJIBOUTI"
  }, {
    code: "DK",
    name: "DENMARK"
  }, {
    code: "DM",
    name: "DOMINICA"
  }, {
    code: "DO",
    name: "DOMINICAN REPUBLIC"
  }, {
    code: "DZ",
    name: "ALGERIA"
  }, {
    code: "EC",
    name: "ECUADOR"
  }, {
    code: "EE",
    name: "ESTONIA"
  }, {
    code: "EG",
    name: "EGYPT"
  }, {
    code: "ER",
    name: "ERITREA"
  }, {
    code: "ES",
    name: "SPAIN"
  }, {
    code: "ET",
    name: "ETHIOPIA"
  }, {
    code: "FI",
    name: "FINLAND"
  }, {
    code: "FJ",
    name: "FIJI"
  }, {
    code: "FK",
    name: "FALKLAND ISLANDS (MALVINAS)"
  }, {
    code: "FM",
    name: "MICRONESIA, FEDERATED STATES OF"
  }, {
    code: "FO",
    name: "FAROE ISLANDS"
  }, {
    code: "FR",
    name: "FRANCE"
  }, {
    code: "GA",
    name: "GABON"
  }, {
    code: "GB",
    name: "UNITED KINGDOM"
  }, {
    code: "GD",
    name: "GRENADA"
  }, {
    code: "GE",
    name: "GEORGIA"
  }, {
    code: "GH",
    name: "GHANA"
  }, {
    code: "GI",
    name: "GIBRALTAR"
  }, {
    code: "GL",
    name: "GREENLAND"
  }, {
    code: "GM",
    name: "GAMBIA"
  }, {
    code: "GN",
    name: "GUINEA"
  }, {
    code: "GQ",
    name: "EQUATORIAL GUINEA"
  }, {
    code: "GR",
    name: "GREECE"
  }, {
    code: "GT",
    name: "GUATEMALA"
  }, {
    code: "GU",
    name: "GUAM"
  }, {
    code: "GW",
    name: "GUINEA-BISSAU"
  }, {
    code: "GY",
    name: "GUYANA"
  }, {
    code: "HK",
    name: "HONG KONG"
  }, {
    code: "HN",
    name: "HONDURAS"
  }, {
    code: "HR",
    name: "CROATIA"
  }, {
    code: "HT",
    name: "HAITI"
  }, {
    code: "HU",
    name: "HUNGARY"
  }, {
    code: "ID",
    name: "INDONESIA"
  }, {
    code: "IE",
    name: "IRELAND"
  }, {
    code: "IL",
    name: "ISRAEL"
  }, {
    code: "IM",
    name: "ISLE OF MAN"
  }, {
    code: "IN",
    name: "INDIA"
  }, {
    code: "IQ",
    name: "IRAQ"
  }, {
    code: "IR",
    name: "IRAN, ISLAMIC REPUBLIC OF"
  }, {
    code: "IS",
    name: "ICELAND"
  }, {
    code: "IT",
    name: "ITALY"
  }, {
    code: "JM",
    name: "JAMAICA"
  }, {
    code: "JO",
    name: "JORDAN"
  }, {
    code: "JP",
    name: "JAPAN"
  }, {
    code: "KE",
    name: "KENYA"
  }, {
    code: "KG",
    name: "KYRGYZSTAN"
  }, {
    code: "KH",
    name: "CAMBODIA"
  }, {
    code: "KI",
    name: "KIRIBATI"
  }, {
    code: "KM",
    name: "COMOROS"
  }, {
    code: "KN",
    name: "SAINT KITTS AND NEVIS"
  }, {
    code: "KP",
    name: "KOREA DEMOCRATIC PEOPLES REPUBLIC OF"
  }, {
    code: "KR",
    name: "KOREA REPUBLIC OF"
  }, {
    code: "KW",
    name: "KUWAIT"
  }, {
    code: "KY",
    name: "CAYMAN ISLANDS"
  }, {
    code: "KZ",
    name: "KAZAKSTAN"
  }, {
    code: "LA",
    name: "LAO PEOPLES DEMOCRATIC REPUBLIC"
  }, {
    code: "LB",
    name: "LEBANON"
  }, {
    code: "LC",
    name: "SAINT LUCIA"
  }, {
    code: "LI",
    name: "LIECHTENSTEIN"
  }, {
    code: "LK",
    name: "SRI LANKA"
  }, {
    code: "LR",
    name: "LIBERIA"
  }, {
    code: "LS",
    name: "LESOTHO"
  }, {
    code: "LT",
    name: "LITHUANIA"
  }, {
    code: "LU",
    name: "LUXEMBOURG"
  }, {
    code: "LV",
    name: "LATVIA"
  }, {
    code: "LY",
    name: "LIBYAN ARAB JAMAHIRIYA"
  }, {
    code: "MA",
    name: "MOROCCO"
  }, {
    code: "MC",
    name: "MONACO"
  }, {
    code: "MD",
    name: "MOLDOVA, REPUBLIC OF"
  }, {
    code: "ME",
    name: "MONTENEGRO"
  }, {
    code: "MF",
    name: "SAINT MARTIN"
  }, {
    code: "MG",
    name: "MADAGASCAR"
  }, {
    code: "MH",
    name: "MARSHALL ISLANDS"
  }, {
    code: "MK",
    name: "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF"
  }, {
    code: "ML",
    name: "MALI"
  }, {
    code: "MM",
    name: "MYANMAR"
  }, {
    code: "MN",
    name: "MONGOLIA"
  }, {
    code: "MO",
    name: "MACAU"
  }, {
    code: "MP",
    name: "NORTHERN MARIANA ISLANDS"
  }, {
    code: "MR",
    name: "MAURITANIA"
  }, {
    code: "MS",
    name: "MONTSERRAT"
  }, {
    code: "MT",
    name: "MALTA"
  }, {
    code: "MU",
    name: "MAURITIUS"
  }, {
    code: "MV",
    name: "MALDIVES"
  }, {
    code: "MW",
    name: "MALAWI"
  }, {
    code: "MX",
    name: "MEXICO"
  }, {
    code: "MY",
    name: "MALAYSIA"
  }, {
    code: "MZ",
    name: "MOZAMBIQUE"
  }, {
    code: "NA",
    name: "NAMIBIA"
  }, {
    code: "NC",
    name: "NEW CALEDONIA"
  }, {
    code: "NE",
    name: "NIGER"
  }, {
    code: "NG",
    name: "NIGERIA"
  }, {
    code: "NI",
    name: "NICARAGUA"
  }, {
    code: "NL",
    name: "NETHERLANDS"
  }, {
    code: "NO",
    name: "NORWAY"
  }, {
    code: "NP",
    name: "NEPAL"
  }, {
    code: "NR",
    name: "NAURU"
  }, {
    code: "NU",
    name: "NIUE"
  }, {
    code: "NZ",
    name: "NEW ZEALAND"
  }, {
    code: "OM",
    name: "OMAN"
  }, {
    code: "PA",
    name: "PANAMA"
  }, {
    code: "PE",
    name: "PERU"
  }, {
    code: "PF",
    name: "FRENCH POLYNESIA"
  }, {
    code: "PG",
    name: "PAPUA NEW GUINEA"
  }, {
    code: "PH",
    name: "PHILIPPINES"
  }, {
    code: "PK",
    name: "PAKISTAN"
  }, {
    code: "PL",
    name: "POLAND"
  }, {
    code: "PM",
    name: "SAINT PIERRE AND MIQUELON"
  }, {
    code: "PN",
    name: "PITCAIRN"
  }, {
    code: "PR",
    name: "PUERTO RICO"
  }, {
    code: "PT",
    name: "PORTUGAL"
  }, {
    code: "PW",
    name: "PALAU"
  }, {
    code: "PY",
    name: "PARAGUAY"
  }, {
    code: "QA",
    name: "QATAR"
  }, {
    code: "RO",
    name: "ROMANIA"
  }, {
    code: "RS",
    name: "SERBIA"
  }, {
    code: "RU",
    name: "RUSSIAN FEDERATION"
  }, {
    code: "RW",
    name: "RWANDA"
  }, {
    code: "SA",
    name: "SAUDI ARABIA"
  }, {
    code: "SB",
    name: "SOLOMON ISLANDS"
  }, {
    code: "SC",
    name: "SEYCHELLES"
  }, {
    code: "SD",
    name: "SUDAN"
  }, {
    code: "SE",
    name: "SWEDEN"
  }, {
    code: "SG",
    name: "SINGAPORE"
  }, {
    code: "SH",
    name: "SAINT HELENA"
  }, {
    code: "SI",
    name: "SLOVENIA"
  }, {
    code: "SK",
    name: "SLOVAKIA"
  }, {
    code: "SL",
    name: "SIERRA LEONE"
  }, {
    code: "SM",
    name: "SAN MARINO"
  }, {
    code: "SN",
    name: "SENEGAL"
  }, {
    code: "SO",
    name: "SOMALIA"
  }, {
    code: "SR",
    name: "SURINAME"
  }, {
    code: "ST",
    name: "SAO TOME AND PRINCIPE"
  }, {
    code: "SV",
    name: "EL SALVADOR"
  }, {
    code: "SY",
    name: "SYRIAN ARAB REPUBLIC"
  }, {
    code: "SZ",
    name: "SWAZILAND"
  }, {
    code: "TC",
    name: "TURKS AND CAICOS ISLANDS"
  }, {
    code: "TD",
    name: "CHAD"
  }, {
    code: "TG",
    name: "TOGO"
  }, {
    code: "TH",
    name: "THAILAND"
  }, {
    code: "TJ",
    name: "TAJIKISTAN"
  }, {
    code: "TK",
    name: "TOKELAU"
  }, {
    code: "TL",
    name: "TIMOR-LESTE"
  }, {
    code: "TM",
    name: "TURKMENISTAN"
  }, {
    code: "TN",
    name: "TUNISIA"
  }, {
    code: "TO",
    name: "TONGA"
  }, {
    code: "TR",
    name: "TURKEY"
  }, {
    code: "TT",
    name: "TRINIDAD AND TOBAGO"
  }, {
    code: "TV",
    name: "TUVALU"
  }, {
    code: "TW",
    name: "TAIWAN, PROVINCE OF CHINA"
  }, {
    code: "TZ",
    name: "TANZANIA, UNITED REPUBLIC OF"
  }, {
    code: "UA",
    name: "UKRAINE"
  }, {
    code: "UG",
    name: "UGANDA"
  }, {
    code: "US",
    name: "UNITED STATES"
  }, {
    code: "UY",
    name: "URUGUAY"
  }, {
    code: "UZ",
    name: "UZBEKISTAN"
  }, {
    code: "VA",
    name: "HOLY SEE (VATICAN CITY STATE)"
  }, {
    code: "VC",
    name: "SAINT VINCENT AND THE GRENADINES"
  }, {
    code: "VE",
    name: "VENEZUELA"
  }, {
    code: "VG",
    name: "VIRGIN ISLANDS, BRITISH"
  }, {
    code: "VI",
    name: "VIRGIN ISLANDS, U.S."
  }, {
    code: "VN",
    name: "VIET NAM"
  }, {
    code: "VU",
    name: "VANUATU"
  }, {
    code: "WF",
    name: "WALLIS AND FUTUNA"
  }, {
    code: "WS",
    name: "SAMOA"
  }, {
    code: "XK",
    name: "KOSOVO"
  }, {
    code: "YE",
    name: "YEMEN"
  }, {
    code: "YT",
    name: "MAYOTTE"
  }, {
    code: "ZA",
    name: "SOUTH AFRICA"
  }, {
    code: "ZM",
    name: "ZAMBIA"
  }, {
    code: "ZW",
    name: "ZIMBABWE"
  }];

@amin-mahmoud
Copy link

amin-mahmoud commented Jul 28, 2021

If it helps

'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','BA','BW','BV','BR','IO','BN','BG','BF','BI','KH','CM','CA','CV','KY','CF','TD','CN',
'CX','CC','CO','KM','CG','CD','CK','CR','CI','HR','CU','CZ','DK','DJ','DM','DO','EC','EG','SV','GQ','ER','EE',
'ET','FK','FO','FJ','FR', 'GF','PF','TF','GA','GM','GE','DE', 'GH','GI','GR','GL','GD','GP','GU','GG',
'GN','GW','GY','HT','HM','VA','HN','HK','HU', 'IS','IN','ID','IR','IQ','IM','IL','IT', 'JM', 'JP', 'JE',
'JO', 'KZ', 'KE', 'KI', 'KR', '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', 'AN', 'NC', 'NZ', 'NI', 'NE', 'NG', 'NU', 'NF', 'MP', 'NO', 'OM',
'PK', 'PW', 'PS', 'PA', 'PG', 'PY', 'PE', 'PH', 'PN', 'PL', 'PT', 'PR', 'QA', 'RE', 'RO', 'RU', 'RW', 'BL', 'SH', 'KN',
'LC', 'MF', 'PM', 'VC', 'WS', 'SM', 'ST', 'SA', 'SN', 'RS', 'SC', 'SL', 'SG', 'SK', 'SI', 'SB', 'SO', 'ZA', 'GS', 'ES', 'LK',
'SD', 'SR', 'SJ', 'SZ', 'SE', 'CH', 'SY', 'TW', 'TJ', 'TZ', 'TH', 'TL', 'TG', 'TK', 'TO', 'TT', 'TN', 'TR', 'TM', 'TC', 'TV',
'UG', 'UA', 'AE', 'GB', 'US', 'UM', 'UY', 'UZ', 'VU', 'VE', 'VN', 'VG', 'VI', 'WF', 'EH', 'YE', 'ZM', 'ZW',
'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','ba','bw','bv','br','io','bn','bg','bf','bi','kh','cm','ca','cv','ky','cf','td','cn',
'cx','cc','co','km','cg','cd','ck','cr','ci','hr','cu','cz','dk','dj','dm','do','ec','eg','sv','gq','er','ee',
'et','fk','fo','fj','fr', 'gf','pf','tf','ga','gm','ge','de', 'gh','gi','gr','gl','gd','gp','gu','gg',
'gn','gw','gy','ht','hm','va','hn','hk','hu', 'is','in','id','ir','iq','im','il','it', 'jm', 'jp', 'je',
'jo', 'kz', 'ke', 'ki', 'kr', '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', 'an', 'nc', 'nz', 'ni', 'ne', 'ng', 'nu', 'nf', 'mp', 'no', 'om',
'pk', 'pw', 'ps', 'pa', 'pg', 'py', 'pe', 'ph', 'pn', 'pl', 'pt', 'pr', 'qa', 're', 'ro', 'ru', 'rw', 'bl', 'sh', 'kn',
'lc', 'mf', 'pm', 'vc', 'ws', 'sm', 'st', 'sa', 'sn', 'rs', 'sc', 'sl', 'sg', 'sk', 'si', 'sb', 'so', 'za', 'gs', 'es', 'lk',
'sd', 'sr', 'sj', 'sz', 'se', 'ch', 'sy', 'tw', 'tj', 'tz', 'th', 'tl', 'tg', 'tk', 'to', 'tt', 'tn', 'tr', 'tm', 'tc', 'tv',
'ug', 'ua', 'ae', 'gb', 'us', 'um', 'uy', 'uz', 'vu', 've', 'vn', 'vg', 'vi', 'wf', 'eh', 'ye', 'zm', 'zw'

@caos30
Copy link

caos30 commented Aug 19, 2021

Traducción al castellano (español)... tirando de wikipedia 😛

<?php

$paises = array(
                    'af' => 'Afganistán',
                    'ax' => 'Aland Islands',
                    'al' => 'Albania',
                    'de' => 'Alemania',
                    'dz' => 'Algeria',
                    'ad' => 'Andorra',
                    'ao' => 'Angola',
                    'ai' => 'Anguila',
                    'aq' => 'Antártida',
                    'ag' => 'Antigua y Barbuda',
                    'an' => 'Antillas Neerlandesas',
                    'sa' => 'Arabia Saudí',
                    'ar' => 'Argentina',
                    'am' => 'Armenia',
                    'aw' => 'Aruba',
                    'au' => 'Australia',
                    'at' => 'Austria',
                    'az' => 'Azerbayán',
                    'bs' => 'Bahamas',
                    'bd' => 'Bangladés',
                    'bb' => 'Barbados',
                    'bh' => 'Baréin',
                    'be' => 'Bélgica',
                    'bz' => 'Belice',
                    'bj' => 'Benín',
                    'bm' => 'Bermudas, Islas',
                    'by' => 'Bielorrusia',
                    'bo' => 'Bolivia',
                    'ba' => 'Bosnia y Herzegovina',
                    'bw' => 'Botswana',
                    'bv' => 'Bouvet',
                    'br' => 'Brasil',
                    'bn' => 'Brunéi Darussalam',
                    'bg' => 'Bulgaria',
                    'bf' => 'Burkina Faso',
                    'bi' => 'Burundi',
                    'bt' => 'Bután',
                    'kh' => 'Camboya',
                    'cm' => 'Camerún',
                    'cv' => 'Cabo Verde',
                    'ca' => 'Canadá',
                    'td' => 'Chad',
                    'cl' => 'Chile',
                    'cn' => 'China',
                    'cy' => 'Chipre',
                    'cc' => 'Cocos (Keeling) Islands',
                    'co' => 'Colombia',
                    'km' => 'Comoros',
                    'cg' => 'Congo',
                    'cd' => 'Congo, Rep. Democrática del',
                    'kp' => 'Corea del Norte',
                    'kr' => 'Corea del Sur',
                    'ci' => 'Costa de Marfil',
                    'cr' => 'Costa Rica',
                    'hr' => 'Croacia',
                    'cu' => 'Cuba',
                    'dk' => 'Dinamarca',
                    'dj' => 'Djibouti',
                    'dm' => 'Dominica',
                    'ec' => 'Ecuador',
                    'eg' => 'Egipto',
                    'sv' => 'El Salvador',
                    'ae' => 'Emiratos Árabes Unidos',
                    'er' => 'Eritrea',
                    'sk' => 'Eslovaquia',
                    'si' => 'Eslovenia',
                    'es' => 'España',
                    'us' => 'Estados Unidos de América',
                    'ee' => 'Estonia',
                    'et' => 'Etiopía',
                    'fj' => 'Fiji',
                    'ph' => 'Filipinas',
                    'fi' => 'Finlandia',
                    'fr' => 'Francia',
                    'ga' => 'Gabón',
                    'gm' => 'Gambia',
                    'ge' => 'Georgia',
                    'gh' => 'Ghana',
                    'gi' => 'Gibraltar',
                    'gd' => 'Granada',
                    'gr' => 'Grecia',
                    'gl' => 'Groenlandia',
                    'gp' => 'Guadalupe',
                    'gu' => 'Guam',
                    'gt' => 'Guatemala',
                    'gy' => 'Guayana',
                    'gf' => 'Guayana Francesa',
                    'gg' => 'Guernsey',
                    'gn' => 'Guinea',
                    'gw' => 'Guinea-Bisáu',
                    'gq' => 'Guinea Ecuatorial',
                    'ht' => 'Haití',
                    'hm' => 'Heard Island & Mcdonald Islands',
                    'hn' => 'Honduras',
                    'hk' => 'Hong Kong',
                    'hu' => 'Hungría',
                    'in' => 'India',
                    'id' => 'Indonesia',
                    'ir' => 'Irán, República Islámica de',
                    'iq' => 'Iraq',
                    'ie' => 'Irlanda',
                    'im' => 'Isla de Man',
                    'cx' => 'Isla Navidad',
                    'nf' => 'Isla Norfolk',
                    'is' => 'Islandia',
                    'ky' => 'Islas Caimán',
                    'ck' => 'Islas Cook',
                    'fo' => 'Islas Feroe',
                    'gs' => 'Islas Georgia y Sandwich del Sur',
                    'fk' => 'Islas Malvinas',
                    'mp' => 'Islas Marianas del Norte',
                    'mh' => 'Islas Marshall',
                    'pn' => 'Islas Pitcairn',
                    'sb' => 'Islas Salomón',
                    'tc' => 'Islas Turcas y Caicos',
                    'um' => 'Islas Ultramarinas Menores de los EEEUU',
                    'vg' => 'Islas Vírgenes Británicas',
                    'vi' => 'Islas Vírgenes de los EEUU',
                    'il' => 'Israel',
                    'it' => 'Italia',
                    'jm' => 'Jamaica',
                    'jp' => 'Japón',
                    'je' => 'Jersey',
                    'jo' => 'Jordán',
                    'kz' => 'Kazajistán',
                    'ke' => 'Kenya',
                    'kg' => 'Kirguistán',
                    'ki' => 'Kiribati',
                    'kw' => 'Kuwait',
                    'la' => 'Laos, Rep. Democr. de Lao',
                    'ls' => 'Lesoto',
                    'lv' => 'Letonia',
                    'lb' => 'Líbano',
                    'lr' => 'Liberia',
                    'ly' => 'Libia',
                    'li' => 'Liechtenstein',
                    'lt' => 'Lituania',
                    'lu' => 'Luxemburgo',
                    'mo' => 'Macao',
                    'mk' => 'Macedonia',
                    'mg' => 'Madagascar',
                    'my' => 'Malasia',
                    'mw' => 'Malaui',
                    'mv' => 'Maldivas',
                    'ml' => 'Mali',
                    'mt' => 'Malta',
                    'ma' => 'Marruecos',
                    'mq' => 'Martinica',
                    'mu' => 'Mauricio',
                    'mr' => 'Mauritania',
                    'yt' => 'Mayotte',
                    'mx' => 'México',
                    'fm' => 'Micronesia, Estados Federados de',
                    'md' => 'Moldavia, República de',
                    'mc' => 'Mónaco',
                    'mn' => 'Mongolia',
                    'me' => 'Montenegro',
                    'ms' => 'Montserrat',
                    'mz' => 'Mozambique',
                    'mm' => 'Myanmar, Birmania',
                    'na' => 'Namibia',
                    'nr' => 'Nauru',
                    'np' => 'Nepal',
                    'ni' => 'Nicaragua',
                    'ne' => 'Níger',
                    'ng' => 'Nigeria',
                    'nu' => 'Niue',
                    'no' => 'Noruega',
                    'nc' => 'Nueva Caledonia',
                    'nz' => 'Nueva Zelanda',
                    'om' => 'Omán',
                    'nl' => 'Países Bajos',
                    'pk' => 'Pakistán',
                    'pw' => 'Palau',
                    'ps' => 'Palestina',
                    'pa' => 'Panamá',
                    'pg' => 'Papúa Nueva Guinea',
                    'py' => 'Paraguay',
                    'pe' => 'Perú',
                    'pf' => 'Polinesia Francesa',
                    'pl' => 'Polonia',
                    'pt' => 'Portugal',
                    'pr' => 'Puerto Rico',
                    'qa' => 'Qatar',
                    'gb' => 'Reino Unido',
                    'cf' => 'República Central Africana',
                    'cz' => 'República Checa',
                    'do' => 'República Dominicana',
                    're' => 'Reunión',
                    'rw' => 'Ruanda',
                    'ro' => 'Rumanía',
                    'ru' => 'Rusia',
                    'eh' => 'Sahara Occidental',
                    'ws' => 'Samoa',
                    'as' => 'Samoa Americana',
                    'bl' => 'San Bartolomé',
                    'kn' => 'San Cristóbal y Nieves',
                    'sm' => 'San Marino',
                    'mf' => 'San Martín',
                    'pm' => 'San Pedro y Miquelón',
                    'vc' => 'San Vicente y Las Granadinas',
                    'sh' => 'Santa Elena',
                    'lc' => 'Santa Lucía',
                    'va' => 'Santa Sede (Cd. Estado del Vaticano)',
                    'st' => 'Santo Tomé y Príncipe',
                    'sn' => 'Senegal',
                    'rs' => 'Serbia',
                    'sc' => 'Seychelles',
                    'sl' => 'Sierra Leona',
                    'sg' => 'Singapur',
                    'sy' => 'Siria, Rep. Árabe de',
                    'so' => 'Somalia',
                    'lk' => 'Sri Lanka',
                    'sz' => 'Suazilandia',
                    'za' => 'Sudáfrica',
                    'sd' => 'Sudán',
                    'se' => 'Suecia',
                    'ch' => 'Suiza',
                    'sr' => 'Surinam',
                    'sj' => 'Svalbard y Jan Mayen',
                    'th' => 'Tailandia',
                    'tw' => 'Taiwán',
                    'tz' => 'Tanzania',
                    'tj' => 'Tayikistán',
                    'io' => 'Territorio Británico del Oc. Índico',
                    'tf' => 'Tierras Australes y Antárticas Francesas',
                    'tl' => 'Timor Oriental',
                    'tg' => 'Togo',
                    'tk' => 'Tokelau',
                    'to' => 'Tonga',
                    'tt' => 'Trinidad y Tobago',
                    'tn' => 'Túnez',
                    'tm' => 'Turkmenistán',
                    'tr' => 'Turquía',
                    'tv' => 'Tuvalu',
                    'ua' => 'Ucrania',
                    'ug' => 'Uganda',
                    'uy' => 'Uruguay',
                    'uz' => 'Uzbekistán',
                    'vu' => 'Vanuatu',
                    've' => 'Venezuela',
                    'vn' => 'Vietnam',
                    'wf' => 'Wallis y Futuna',
                    'ye' => 'Yemen',
                    'zm' => 'Zambia',
                    'zw' => 'Zimbabue'
                );
?>
  • Editado 2021-08-19: faltaba traducir Noruega.
  • Editado 2021-08-19: faltaba agregar 'kp' (Corea del Norte) y cambiar 'kr' a Corea del Sur.

@caos30
Copy link

caos30 commented Aug 19, 2021

Array of VAT by country (maximum VAT on the country).
Taken from here (quite outdated... 2012!!): https://economipedia.com/ranking/el-iva-en-el-mundo.html

<?php 

$vat_by_country = array(
            'hu' => 27,
            'hr' => 25,
            'dk' => 25,
            'no' => 25,
            'se' => 25,
            'fi' => 24,
            'is' => 24,
            'ro' => 24,
            'gr' => 23,
            'ie' => 23,
            'pl' => 23,
            'pt' => 23,
            'it' => 22,
            'uy' => 22,
            'ar' => 21,
            'be' => 21,
            'nl' => 21,
            'es' => 21,
            'fr' => 20,
            'ma' => 20,
            'gb' => 20,
            'cl' => 19,
            'de' => 19,
            'br' => 19,
            'pe' => 18,
            'do' => 18,
            'ru' => 18,
            'cn' => 17,
            'mx' => 16,
            'co' => 16,
            'hn' => 15,
            'ni' => 15,
            'in' => 15,
            'za' => 14,
            'bo' => 13,
            'cr' => 13,
            'sv' => 13,
            'ec' => 12,
            'gt' => 12,
            've' => 12,
            'pr' => 11.5,
            'au' => 10,
            'kr' => 10,
            'py' => 10,
            'jp' => 8,
            'ch' => 8,
            'pa' => 7,
            'ca' => 5,
            'us' => 11.7
            );
    }
?>

@stephb9959
Copy link

stephb9959 commented Oct 8, 2021

In case this is useful for anyone, the country codes above for C++..

    struct CountryInfo {
        std::string     code;
        std::string     name;
    };
    
    static const std::vector<CountryInfo> CountryCodes {
        { .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" }
    };

@charithar
Copy link

charithar commented May 25, 2022

Thanks. If somebody needs only the list of codes then,

$countryCodes = ['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', 'BA', 'BW', 'BV', 'BR', 'IO', 'BN', 'BG', 'BF', 'BI', 'KH', 'CM', 'CA', 'CV', 'KY', 'CF', 'TD', 'CL', 'CN', 'CX', 'CC', 'CO', 'KM', 'CG', 'CD', 'CK', 'CR', 'CI', 'HR', 'CU', 'CY', 'CZ', 'DK', 'DJ', 'DM', 'DO', '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', 'VA', 'HN', 'HK', 'HU', 'IS', 'IN', 'ID', 'IR', 'IQ', 'IE', 'IM', 'IL', 'IT', 'JM', 'JP', 'JE', 'JO', 'KZ', 'KE', 'KI', 'KR', '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', 'AN', 'NC', 'NZ', 'NI', 'NE', 'NG', 'NU', 'NF', 'MP', 'NO', 'OM', 'PK', 'PW', 'PS', 'PA', 'PG', 'PY', 'PE', 'PH', 'PN', 'PL', 'PT', 'PR', 'QA', 'RE', 'RO', 'RU', 'RW', 'BL', 'SH', 'KN', 'LC', 'MF', 'PM', 'VC', 'WS', 'SM', 'ST', 'SA', 'SN', 'RS', 'SC', 'SL', 'SG', 'SK', 'SI', 'SB', 'SO', 'ZA', 'GS', 'ES', 'LK', 'SD', 'SR', 'SJ', 'SZ', 'SE', 'CH', 'SY', 'TW', 'TJ', 'TZ', 'TH', 'TL', 'TG', 'TK', 'TO', 'TT', 'TN', 'TR', 'TM', 'TC', 'TV', 'UG', 'UA', 'AE', 'GB', 'US', 'UM', 'UY', 'UZ', 'VU', 'VE', 'VN', 'VG', 'VI', 'WF', 'EH', 'YE', 'ZM', 'ZW'];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment