PHP code example of blakroku / countries

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

    

blakroku / countries example snippets


use Blakroku\Countries\Countries\CountryManager;

$manager = new CountryManager();

// Get all countries
$countries = $manager->getAllCountries();

// Get country by name
$kenya = $manager->getCountryByName('Kenya');

// Get country by ISO code
$us = $manager->getCountryByCode('US');

// Get country by domain extension
$country = $manager->getCountryByDomainExtension('.fr');

// Get country by calling code
$country = $manager->getCountryByCallingCode('+49');

// Get country by currency
$country = $manager->getCountryByCurrency('EUR');

// Get country by capital
$country = $manager->getCountryByCapital('Tokyo');