A PHP library providing ISO 3166-1 data.
$ composer require zhuravel/php-iso-3166-1
<?php
require 'vendor/autoload.php';
$canada1 = getTwoCharacterCountries()['CA'];
$canada2 = getThreeCharacterCountries()['CAN'];
$canada3 = getNumericCountryCodes()['124'];
var_dump($canada1, $canada2, $canada3);
<?php
require 'vendor/autoload.php';
foreach (getTwoCharacterCountries() as $code => $name) {
echo sprintf("%s %s\n", $code, $name);
}
<?php
require 'vendor/autoload.php';
use Iso\Countries\Factory\ISO3166CountryFactory;
$factory = new ISO3166CountryFactory();
$canada = $factory->fromAlphaTwoCode('CA');
var_dump($canada);
- ISO 3166-1 by Wikipedia licensed under CC BY-SA 3.0 Unported License
- www.iso.org