PHP Classes

PHP Country Code to Country Name: Validate country code and get the respective name

Recommend this page to a friend!
  Info   View files Documentation   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 313 All time: 7,280 This week: 206Up
Version License PHP version Categories
countrycode 1.0.4Custom (specified...5PHP 5, Geography, Validation


This class can validate country code and get the respective name.

It can take a given country code with two letters and determine if it corresponds to a valid country.

The class can also get the name of a country given the respective two letter code.

Innovation Award
PHP Programming Innovation award nominee
September 2018
Number 4
Many applications need to take the country code as parameter for their own purposes.

This class can take the two letter code of country and determine if it corresponds to a valid code. It can also return the respective country name.

Manuel Lemos
Picture of Peter Kahl
  Performance   Level  
Name: Peter Kahl <contact>
Classes: 37 packages by
Country: United Kingdom
Age: ???
All time rank: 41721 in United Kingdom
Week rank: 286 Up10 in United Kingdom Up
Innovation award
Innovation award
Nominee: 23x

Winner: 2x



Downloads License If this project has business value for you then don't hesitate to support me with a small donation.

Methods for working with 2-character country codes (validation, name from code).


When using method getName(), multibyte strings will be returned.

Usage Exaples

use peterkahl\CountryCode\CountryCode;

# Validate a country code string:
if (CountryCode::isValid('uk'))
  echo 'valid';
  echo 'invalid';

# Get name from country code:
echo CountryCode::getName('RE'); # Réunion

  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file CountryCode.php Class Class source

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:7,280
This week:206Up