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
2019-10-11 (5 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: 280 All time: 7,446 This week: 357Up
Version License PHP version Categories
countrycode 1.0.4Custom (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
Innovation award
Innovation award
Nominee: 23x

Winner: 2x

 

Details

CountryCode

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

??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:280
This week:0
All time:7,446
This week:357Up