Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8436549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:12:26+00:00 2026-06-10T07:12:26+00:00

Is there a way to convert country name to country code abbreviation? Or some

  • 0

Is there a way to convert country name to country code abbreviation? Or some php function?

So that when its “Australia” it will be changed to “AU”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:12:28+00:00Added an answer on June 10, 2026 at 7:12 am

    PHP itself has no knowledge of these values. You have to create your own code:

    Method 1:

    Create an array like:

    $COUNTRY = array(
      "Australia" => "AU",
      "Germany" => "GER"
      ...
    );
    

    After that, just use the pre0stored values:

    echo $COUNTRY['Australia'];
    

    Method 2 ( suggested ):

    Store the values into DB:

    +-----------+------+
    | Country   | Code |
    +-----------+------+
    | Australia | AU   |
    | Germany   | GER  |
    ...
    +-----------+------+
    

    And Access with simple query:

    SELECT Code FROM country_db WHERE Country = 'Australia';
    

    EDIT

    CREATE TABLE
        country_code
    (
        code,
        country
    );
    
    INSERT INTO
        country_code
        ( code, country )
    VALUES
        ( '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 the' ),
        ( '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 (Bouvetoya)' ),
        ( 'BR', 'Brazil' ),
        ( 'IO', 'British Indian Ocean Territory (Chagos Archipelago)' ),
        ( 'VG', 'British Virgin Islands' ),
        ( '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 the' ),
        ( 'CD', 'Congo' ),
        ( 'CG', 'Congo the' ),
        ( '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' ),
        ( 'FO', 'Faroe Islands' ),
        ( 'FK', 'Falkland Islands (Malvinas)' ),
        ( 'FJ', 'Fiji the Fiji Islands' ),
        ( 'FI', 'Finland' ),
        ( 'FR', 'France, French Republic' ),
        ( 'GF', 'French Guiana' ),
        ( 'PF', 'French Polynesia' ),
        ( 'TF', 'French Southern Territories' ),
        ( 'GA', 'Gabon' ),
        ( 'GM', 'Gambia the' ),
        ( 'GE', 'Georgia' ),
        ( 'DE', 'Germany' ),
        ( 'GH', 'Ghana' ),
        ( 'GI', 'Gibraltar' ),
        ( 'GR', 'Greece' ),
        ( 'GL', 'Greenland' ),
        ( 'GD', 'Grenada' ),
        ( 'GP', 'Guadeloupe' ),
        ( 'GU', 'Guam' ),
        ( 'GT', 'Guatemala' ),
        ( 'GG', 'Guernsey' ),
        ( 'GN', 'Guinea' ),
        ( 'GW', 'Guinea-Bissau' ),
        ( 'GY', 'Guyana' ),
        ( 'HT', 'Haiti' ),
        ( 'HM', 'Heard Island and McDonald Islands' ),
        ( 'VA', 'Holy See (Vatican City State)' ),
        ( 'HN', 'Honduras' ),
        ( 'HK', 'Hong Kong' ),
        ( 'HU', 'Hungary' ),
        ( 'IS', 'Iceland' ),
        ( 'IN', 'India' ),
        ( 'ID', 'Indonesia' ),
        ( 'IR', 'Iran' ),
        ( 'IQ', 'Iraq' ),
        ( 'IE', 'Ireland' ),
        ( 'IM', 'Isle of Man' ),
        ( 'IL', 'Israel' ),
        ( 'IT', 'Italy' ),
        ( 'JM', 'Jamaica' ),
        ( 'JP', 'Japan' ),
        ( 'JE', 'Jersey' ),
        ( 'JO', 'Jordan' ),
        ( 'KZ', 'Kazakhstan' ),
        ( 'KE', 'Kenya' ),
        ( 'KI', 'Kiribati' ),
        ( 'KP', 'Korea' ),
        ( 'KR', 'Korea' ),
        ( 'KW', 'Kuwait' ),
        ( 'KG', 'Kyrgyz Republic' ),
        ( 'LA', 'Lao' ),
        ( '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' ),
        ( 'MD', 'Moldova' ),
        ( 'MC', 'Monaco' ),
        ( 'MN', 'Mongolia' ),
        ( 'ME', 'Montenegro' ),
        ( 'MS', 'Montserrat' ),
        ( 'MA', 'Morocco' ),
        ( 'MZ', 'Mozambique' ),
        ( 'MM', 'Myanmar' ),
        ( 'NA', 'Namibia' ),
        ( 'NR', 'Nauru' ),
        ( 'NP', 'Nepal' ),
        ( 'AN', 'Netherlands Antilles' ),
        ( 'NL', 'Netherlands the' ),
        ( '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' ),
        ( 'PA', 'Panama' ),
        ( 'PG', 'Papua New Guinea' ),
        ( 'PY', 'Paraguay' ),
        ( 'PE', 'Peru' ),
        ( 'PH', 'Philippines' ),
        ( 'PN', 'Pitcairn Islands' ),
        ( 'PL', 'Poland' ),
        ( 'PT', 'Portugal, Portuguese Republic' ),
        ( '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 the Grenadines' ),
        ( 'WS', 'Samoa' ),
        ( 'SM', 'San Marino' ),
        ( 'ST', 'Sao Tome and Principe' ),
        ( 'SA', 'Saudi Arabia' ),
        ( 'SN', 'Senegal' ),
        ( 'RS', 'Serbia' ),
        ( 'SC', 'Seychelles' ),
        ( 'SL', 'Sierra Leone' ),
        ( 'SG', 'Singapore' ),
        ( 'SK', 'Slovakia (Slovak Republic)' ),
        ( 'SI', 'Slovenia' ),
        ( 'SB', 'Solomon Islands' ),
        ( 'SO', 'Somalia, Somali Republic' ),
        ( 'ZA', 'South Africa' ),
        ( 'GS', 'South Georgia and the South Sandwich Islands' ),
        ( 'ES', 'Spain' ),
        ( 'LK', 'Sri Lanka' ),
        ( 'SD', 'Sudan' ),
        ( 'SR', 'Suriname' ),
        ( 'SJ', 'Svalbard & Jan Mayen Islands' ),
        ( 'SZ', 'Swaziland' ),
        ( 'SE', 'Sweden' ),
        ( 'CH', 'Switzerland, Swiss Confederation' ),
        ( '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 of America' ),
        ( 'UM', 'United States Minor Outlying Islands' ),
        ( 'VI', 'United States Virgin Islands' ),
        ( 'UY', 'Uruguay, Eastern Republic of' ),
        ( 'UZ', 'Uzbekistan' ),
        ( 'VU', 'Vanuatu' ),
        ( 'VE', 'Venezuela' ),
        ( 'VN', 'Vietnam' ),
        ( 'WF', 'Wallis and Futuna' ),
        ( 'EH', 'Western Sahara' ),
        ( 'YE', 'Yemen' ),
        ( 'ZM', 'Zambia' ),
        ( 'ZW', 'Zimbabwe' );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to convert .so file into source code or some in
Using Java, Is there a quick way to convert an alpha-2 country code (IN
Is there a way to convert twitter bootstrap's typeahead function into a $(body).on() function?
Is there a way to convert an integer to a string in PHP?
Is there a way to convert HTML into XAML? I noticed that you can
is there a way to convert byte[] to its original file format? Byte[] tempByte
Is there a good way to convert Regular Expression into LIKE inside a Function
Is there any way to convert the warning that MySQL is issuing about an
Is there any way to convert the llvm IR to c code and keep
In .NET is there any way to convert from three letter country codes (defined

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.