Skip to content

Instantly share code, notes, and snippets.

@vxnick
Created April 27, 2010 15:52
Show Gist options
  • Select an option

  • Save vxnick/380904 to your computer and use it in GitHub Desktop.

Select an option

Save vxnick/380904 to your computer and use it in GitHub Desktop.
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',
);
?>
@durangod
Copy link

durangod commented Jan 5, 2026

Hi, here is a different format for the array, a much simpler version. Alittle bit of find and replace and some keyboard work and whalla! I still have NOT checked codes against these resources:

https://en.wikipedia.org/wiki/List_of_telephone_country_codes (scroll to very bottom of the page)
https://countrycode.org

But i do plan to verify against those resources soon. Thanks to the github developer for taking the time to provide the original listing here.

Here is my version of the simpler array (php)

$country_phone_codes = [
'UK' => '44',
'USA' => '1',
'Algeria' => '213',
'Andorra' => '376',
'Angola' => '244',
'Anguilla' => '1264',
'Antigua & Barbuda' => '1268',
'Argentina' => '54',
'Armenia' => '374',
'Aruba' => '297',
'Australia' => '61',
'Austria' => '43',
'Azerbaijan' => '994',
'Bahamas' => '1242',
'Bahrain' => '973',
'Bangladesh' => '880',
'Barbados' => '1246',
'Belarus' => '375',
'Belgium' => '32',
'Belize' => '501',
'Benin' => '229',
'Bermuda' => '1441',
'Bhutan' => '975',
'Bolivia' => '591',
'Bosnia & Herzegovina' => '387',
'Botswana' => '267',
'Brazil' => '55',
'Brunei' => '673',
'Bulgaria' => '359',
'Burkina Faso' => '226',
'Burundi' => '257',
'Cambodia' => '855',
'Cameroon' => '237',
'Canada' => '1',
'Cape Verde' => '238',
'Cayman Islands' => '1345',
'Central African Republic' => '236',
'Chile' => '56',
'China' => '86',
'Colombia' => '57',
'Comoros' => '269',
'Congo' => '242',
'Congo (Democratic Republic)' => '243',
'Cook Islands' => '682',
'Costa Rica' => '506',
'Croatia' => '385',
'Cuba' => '53',
'Cyprus' => '357',
'Czech Republic' => '420',
'Denmark' => '45',
'Djibouti' => '253',
'Dominica' => '1767',
'Dominican Republic' => '1-809',
'Ecuador' => '593',
'Egypt' => '20',
'El Salvador' => '503',
'Equatorial Guinea' => '240',
'Eritrea' => '291',
'Estonia' => '372',
'Ethiopia' => '251',
'Falkland Islands' => '500',
'Faroe Islands' => '298',
'Fiji' => '679',
'Finland' => '358',
'France' => '33',
'French Guiana' => '594',
'French Polynesia' => '689',
'Gabon' => '241',
'Gambia' => '220',
'Georgia' => '995',
'Germany' => '49',
'Ghana' => '233',
'Gibraltar' => '350',
'Greece' => '30',
'Greenland' => '299',
'Grenada' => '1473',
'Guadeloupe' => '590',
'Guam' => '1671',
'Guatemala' => '502',
'Guinea' => '224',
'Guinea-Bissau' => '245',
'Guyana' => '592',
'Haiti' => '509',
'Honduras' => '504',
'Hong Kong' => '852',
'Hungary' => '36',
'Iceland' => '354',
'India' => '91',
'Indonesia' => '62',
'Iran' => '98',
'Iraq' => '964',
'Ireland' => '353',
'Israel' => '972',
'Italy' => '39',
'Jamaica' => '1876',
'Japan' => '81',
'Jordan' => '962',
'Kazakhstan' => '7',
'Kenya' => '254',
'Kiribati' => '686',
'Korea North' => '850',
'Korea South' => '82',
'Kuwait' => '965',
'Kyrgyzstan' => '996',
'Laos' => '856',
'Latvia' => '371',
'Lebanon' => '961',
'Lesotho' => '266',
'Liberia' => '231',
'Libya' => '218',
'Liechtenstein' => '423',
'Lithuania' => '370',
'Luxembourg' => '352',
'Macao' => '853',
'Macedonia' => '389',
'Madagascar' => '261',
'Malawi' => '265',
'Malaysia' => '60',
'Maldives' => '960',
'Mali' => '223',
'Malta' => '356',
'Marshall Islands' => '692',
'Martinique' => '596',
'Mauritania' => '222',
'Mauritius' => '230',
'Mayotte' => '262',
'Mexico' => '52',
'Micronesia' => '691',
'Moldova' => '373',
'Monaco' => '377',
'Mongolia' => '976',
'Montserrat' => '1664',
'Morocco' => '212',
'Mozambique' => '258',
'Myanmar' => '95',
'Namibia' => '264',
'Nauru' => '674',
'Nepal' => '977',
'Netherlands' => '31',
'New Caledonia' => '687',
'New Zealand' => '64',
'Nicaragua' => '505',
'Niger' => '227',
'Nigeria' => '234',
'Niue' => '683',
'Norfolk Islands' => '672',
'Northern Marianas' => '1670',
'Norway' => '47',
'Oman' => '968',
'Palau' => '680',
'Panama' => '507',
'Papua New Guinea' => '675',
'Paraguay' => '595',
'Peru' => '51',
'Philippines' => '63',
'Poland' => '48',
'Portugal' => '351',
'Puerto Rico' => '1787',
'Qatar' => '974',
'Reunion' => '262',
'Romania' => '40',
'Russia' => '7',
'Rwanda' => '250',
'San Marino' => '378',
'Sao Tome & Principe' => '239',
'Saudi Arabia' => '966',
'Senegal' => '221',
'Serbia' => '381',
'Seychelles' => '248',
'Sierra Leone' => '232',
'Singapore' => '65',
'Slovak Republic' => '421',
'Slovenia' => '386',
'Solomon Islands' => '677',
'Somalia' => '252',
'South Africa' => '27',
'Spain' => '34',
'Sri Lanka' => '94',
'St. Helena' => '290',
'St. Kitts' => '1869',
'St. Lucia' => '1758',
'Sudan' => '249',
'Suriname' => '597',
'Swaziland' => '268',
'Sweden' => '46',
'Switzerland' => '41',
'Syria' => '963',
'Taiwan' => '886',
'Tajikistan' => '992',
'Thailand' => '66',
'Togo' => '228',
'Tonga' => '676',
'Trinidad & Tobago' => '1868',
'Tunisia' => '216',
'Turkey' => '90',
'Turkmenistan' => '993',
'Turks & Caicos Islands' => '1649',
'Tuvalu' => '688',
'Uganda' => '256',
'Ukraine' => '380',
'United Arab Emirates' => '971',
'Uruguay' => '598',
'Uzbekistan' => '998',
'Vanuatu' => '678',
'Vatican City' => '379',
'Venezuela' => '58',
'Vietnam' => '84',
'Virgin Islands - British' => '1284',
'Virgin Islands - US' => '1340',
'Wallis & Futuna' => '681',
'Yemen' => '967',
'Zambia' => '260',
'Zimbabwe' => '263'
];

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