PHP Classes
elePHPant
Icontem

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    
Last Updated Ratings Unique User Downloads Download Rankings
2018-10-31 (3 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 267 This week: 1All time: 7,521 This week: 455Up
Version License PHP version Categories
countrycode 1.0.2Custom (specified...5PHP 5, Geography, Validation
Description Author

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
  Performance   Level  
Name: Peter Kahl <contact>
Classes: 37 packages by
Country: United Kingdom United Kingdom
Age: ???
All time rank: 53727 in United Kingdom United Kingdom
Week rank: 10 Up1 in United Kingdom United Kingdom Up
Innovation award
Innovation award
Nominee: 22x

Winner: 2x

Details

CountryCode

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).

??CAUTION

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';
}
else
{
  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 README.md 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  
 100%
Total:267
This week:1
All time:7,521
This week:455Up