PHP code example of crcl / worlddata

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

    

crcl / worlddata example snippets


$oContinents = \CRCL\worlddata\World::continents(); // all continents

$oContinent = \CRCL\worlddata\World::continents()->find('EU'); // Continent instance
$oContinent->code; // EU
$oContinent->name; // Europe
$oContinent->countries(); // [CountryObj1, CountryObj2,..]

$oCountry = \crcl\worlddata\World::countries()->find('DE'); // or use shortcut ::countries('DE')
$oCountry->name; // Germany
$oCountry->coordinates; // [latitude , longitude] of country center
$oCountry->timezones; // [["Europe/Berlin", null]] Countries with multiple time-zones are represented by an array of time-zone name and time-zone longitude pairs.
$oCountry->tld; // .de
$oCountry->continent; // EU
$oCountry->continent(); // ContinentObj

// additional data sets
\crcl\worlddata\World::currencies();
\crcl\worlddata\World::languages();
\crcl\worlddata\World::topLevelDomains();

// useful samples
\crcl\worlddata\World::countries()->groupBy('continent'); // countries grouped by continents
\crcl\worlddata\World::countries()->contains('name', 'Germany') // check by any property
\crcl\worlddata\World::currencies()->exist('USD'); // check by code true
// etc..