PHP code example of awoods / world

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

    

awoods / world example snippets




$usa = Awoods\World\CountryFactory::get('US');
echo $usa->getOfficialName(); // Unites States of America

$canada = Awoods\World\CountryFactory::get('CAN');
echo $canada->getCommonName(); // Canada



$countryFactory = new \Awoods\World\CountryFactory();
$countries = $countryFactory->getAllCountries();

foreach ($countries AS $code => $name) {
    echo "\n";
    echo "{$code} is the code for {$name}\n";

    $country = $countryFactory->create($code);

    echo "The official name for {$name} is '{$country->getFullName()}'\n";
    echo "Here is a list of it's localities:\n";

    foreach ($country->getLocalityList() AS $localityCode => $localityName) {
        echo "* {$localityName} ({$localityCode})\n";
    }
}
echo "\n";