PHP code example of phine / country

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

    

phine / country example snippets


use Phine\Country\Loader\Loader;

$loader = new Loader();

// returns data for "US"
$country = $loader->loadCountry('US');

echo $country->getAlpha2Code(); // "US"
echo $country->getAlpha3Code(); // "USA"
echo $country->getLongName(); // "United States of America"
echo $country->getNumericCode(); // "840"
echo $country->getShortName(); // "United States"

// returns all countries
$countries = $loader->loadCountries();

$country = $countries['US'];

// returns data for "US-CA"
$subdivision = $loader->loadSubdivision('US-CA');

echo $subdivision->getCode(); // "US-CA"
echo $subdivision->getName(); // "California"

// returns all subdivisions
$subdivisions = $loader->loadSubdivisions();

$subdivision = $subdivisions['US-CA'];

// returns all subdivisions for a specific country
$subdivisions = $loader->loadSubdivisions('US');