PHP code example of oldcodefork / isocountries

1. Go to this page and download the library: Download oldcodefork/isocountries 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/ */

    

oldcodefork / isocountries example snippets



use BrightfishSoftware\IsoCountries;

$countries = new IsoCountries;
print_r($countries->get()); // as ISO3
print_r($countries->get(IsoCountries::RETURN_AS_ISO2)); // as ISO2


use BrightfishSoftware\IsoCountries;

$countries = new IsoCountries;
print_r($countries->toTop('GBR')->get());


use BrightfishSoftware\IsoCountries;

$countries = new IsoCountries;
print_r($countries->exclude(['AFG', 'ALA', 'ALB'])->get());


use BrightfishSoftware\IsoCountries;

$countries = new IsoCountries;
print_r($countries->getEu()); // all EU
print_r($countries->toTop('GBR')->getEu()); // all EU but move GBR to top


use BrightfishSoftware\IsoCountries;

$countries = new IsoCountries;
echo $countries->getName('GBR');
echo $countries->getName('GB');


use BrightfishSoftware\IsoCountries;

$countries = new IsoCountries;
echo $countries->getIso3Code('United Kingdom');
echo $countries->getIso2Code('United Kingdom');