PHP code example of graftak / country-code-helper

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

    

graftak / country-code-helper example snippets


use Graftak\CountryCodeHelper;
use Graftak\CountryCodeHelper\CountryCodes;

CountryCodeHelper::map($value, $toType);



use Graftak\CountryCodeHelper;
use Graftak\CountryCodeHelper\CountryCodes;

// Example 1 (The Netherlands): Two-letter to three-letter code.
print CountryCodeHelper::map('NL', CountryCodes::ALPHA_3);
// Output: 'NLD'

// Example 2 (Philippines): Numeric to two-letter code.
print CountryCodeHelper::map(608, CountryCodes::ALPHA_2);
// Output: 'PH'

// Example 3 (Virgin Islands): Two-letter to English name.
print CountryCodeHelper::map('VG', CountryCodes::SHORT_NAME_ENGLISH);
// Output: 'Virgin Islands (British)'