PHP code example of adamb / uk-counties

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

    

adamb / uk-counties example snippets




use UKCounties\Counties;

print_r(Counties::getCounties()); // Returns array of counties e.g. array(1 => 'Bedfordshire', 2 => 'Berkshire', 3 => 'Bristol', etc, etc, etc)

// To list the counties in alphabetical order you can use getCountiesByName() instead of getCounties()
print_r(Counties::getCountiesByName()); // Returns same as above but in alphabetical order




use UKCounties\Counties;

echo(Counties::getCountyID('West Yorkshire')); // Returns 46

echo(Counties::getCountyID('Aberdeenshire')); // Returns 60




use UKCounties\Counties;

echo(Counties::getCountyName(46)); // Returns "West Yorkshire"

echo(Counties::getCountyName(60)); // Returns "Aberdeenshire"