PHP code example of mrferrys / librestcountries
1. Go to this page and download the library: Download mrferrys/librestcountries 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/ */
mrferrys / librestcountries example snippets
use librestcountries\restCountriesClient as rcClient;
$restClient = new rcClient();
$restClient->urlBase = "https://restcountries.com/v3.1/";
$result = $restClient->listAll();
foreach($result as $key=>$value)
{
$name=$value->name->common;
echo ".- $name ".PHP_EOL;
}
$field = "name";
$value = "spain";
$result = $restClient->filterBy($field,$value);
foreach($result as $key=>$value)
{
$name=$value->name->common;
$official=$value->name->official;
echo ".- $name/$official ".PHP_EOL;
}