PHP code example of markenwerk / iso3166-country-information

1. Go to this page and download the library: Download markenwerk/iso3166-country-information library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

markenwerk / iso3166-country-information example snippets

`{php}  
$arrayOfIso3166Countries = Iso3166CountryInformation::getCountryData();
`{php}
$arrayOfIso3166CountryObjects = Iso3166CountryInformation::getCountries();
`{php}
$iso3166Country = Iso3166CountryInformation::getByIso3166Alpha2('de');
`{php}
$iso3166Country = Iso3166CountryInformation::getByIso3166Alpha3('deu');
`{php}
$iso3166Country = Iso3166CountryInformation::getByIso3166Numeric(276);
`{php}
$iso3166Country = Iso3166CountryInformation::getByIso3166v2('de');
`{php}
$iso3166Country = Iso3166CountryInformation::getByToplevelDomain('de');
`{php}
$iso3166Country = Iso3166CountryInformation::getByUnitedNationsId('de');
`{php}
$countryExists = Iso3166CountryInformation::validateIso3166Alpha2('de');
`{php}
$countryExists = Iso3166CountryInformation::validateIso3166Alpha3('deu');
`{php}
$countryExists = Iso3166CountryInformation::validateIso3166Numeric(276);
`{php}
$countryExists = Iso3166CountryInformation::validateIso3166v2('de');
`{php}
$countryExists = Iso3166CountryInformation::validateToplevelDomain('de');
`{php}
$countryExists = Iso3166CountryInformation::validateUnitedNationsId('de');
`{php}
use Iso3166Country\Iso3166CountryInformation;
use Iso3166Country\Iso3166Country;

$utopia = array(
	Iso3166CountryInformation::ISO3166_ALPHA2 => 'UO',
	Iso3166CountryInformation::ISO3166_ALPHA3 => 'UTO',
	Iso3166CountryInformation::ISO3166_NUMERIC => 42,
	Iso3166CountryInformation::ISO3166_2 => 'UO',
	Iso3166CountryInformation::UNITED_NATIONS_ID => 'uo',
	Iso3166CountryInformation::TOP_LEVEL_DOMAIN => 'uo',
	Iso3166CountryInformation::NAME => 'Utopia'
);
$country = new Iso3166Country();
$country->loadByIso3166CountryInformation($utopia);
`{php}
$iso3166Alpha2 = $country->getIso3166Alpha2CountryCode();
$iso3166Alpha3 = $country->getIso3166Alpha3CountryCode();
$iso3166Numeric = $country->getIso3166NumericCountryCode();
$iso3166_2 = $country->getIso3166v2CountryCode();
$toplevelDomain = $country->getToplevelDomain();
$unitedNationsIdentifier = $country->getUnitedNationsId();
$name = $country->getName();