PHP code example of sameer-shelavale / php-countries-array

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

    

sameer-shelavale / php-countries-array example snippets


{
    "  "sameer-shelavale/php-countries-array": "*"
    }
}

$countries = CountriesArray::get( 'alpha2', 'name' ); // returns alpha2->name array
$countries = CountriesArray::get( 'num', 'alpha3' ); // return numeric-codes->alpha3 array
$countries = CountriesArray::get( 'num', 'name' ); // return numeric-codes->name array

$countries = CountriesArray::get( null, 'name' ); // return array of country names
$countries = CountriesArray::get( null, 'alpha2' ); // return array of alpha2 codes

$countries = CountriesArray::get2d( null, 'name' ); // return array of country names
$countries = CountriesArray::get2d( null, 'alpha2' ); // return array of alpha2 codes