library countrynames
A PHP library to work with localized country names
mlocati/countrynames
A PHP library to work with localized country names
- Monday, November 21, 2016
- by mlocati
- Repository
- 1 Watchers
- 2 Stars
- 40 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 2 Versions
- 3 % Grown
PHP library to recognize localized country names thanks to Unicode CLDR
Features
- Understand a lot of languages (almost 150 - but some language may not be complete).
- Works with PHP 5.3+
- Requires the mb_string PHP extension (or any package that implements mb_strtolower for UTF-8)
Install
With composer
composer require mlocati/countrynames, (*1)
Without composer
<?php
require_once 'autoload.php';
Sample usage
use MLocati\CountryNames\CountryList;
require_once 'autoload.php'; // Not required if you use composer
$italianList = new CountryList('it');
$italianCountry = $italianList->getCountryByName('italia');
$englishList = new CountryList('en');
$englishCountry = $englishList->getCountryByCode($italianCountry->getCode());
echo $englishCountry->getCanonicalName(); // Dumps 'Italy'