mlocati/countrynames

A PHP library to work with localized country names

1.0.0 2016-11-21 15:09 UTC

This package is auto-updated.

Last update: 2024-10-13 04:41:38 UTC


README

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

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'