adamb / uk-counties
A PHP list of UK counties
v1.0.1
2018-03-01 11:24 UTC
Requires (Dev)
- phpunit/phpunit: ^6.4
This package is auto-updated.
Last update: 2024-11-20 21:05:32 UTC
README
UK Counties PHP
Produces a list of UK counties using PHP. Can be used to store county ID's rather than names.
Installation
Installation is available via Composer/Packagist, you can add the following line to your composer.json
file:
"adamb/uk-counties": "^1.0"
or
composer require adamb/uk-counties
License
This software is distributed under the MIT license. Please read LICENSE for information on the software availability and distribution.
Usage
List Counties
<?php 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
Get County ID By Name
This can be used to store a unique county ID in a database rather than duplicating information.
<?php use UKCounties\Counties; echo(Counties::getCountyID('West Yorkshire')); // Returns 46 echo(Counties::getCountyID('Aberdeenshire')); // Returns 60
Get County Name By ID
<?php use UKCounties\Counties; echo(Counties::getCountyName(46)); // Returns "West Yorkshire" echo(Counties::getCountyName(60)); // Returns "Aberdeenshire"