adamb/uk-counties

英国郡列表的PHP脚本

v1.0.1 2018-03-01 11:24 UTC

This package is auto-updated.

Last update: 2024-09-20 20:41:44 UTC


README

Build Status Scrutinizer Quality Score Minimum PHP Version Scrutinizer Coverage

UK Counties PHP

使用PHP生成英国郡列表。可以用来存储郡ID而不是名称。

安装

安装可通过 Composer/Packagist 进行,您可以将以下行添加到您的 composer.json 文件中

"adamb/uk-counties": "^1.0"

或者

composer require adamb/uk-counties

许可证

本软件在MIT许可证下分发。请阅读LICENSE以获取有关软件可用性和分发的信息。

使用方法

列出郡

<?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

通过名称获取郡ID

这可以用来在数据库中存储唯一的郡ID而不是重复信息。

<?php

use UKCounties\Counties;

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

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

通过ID获取郡名称

<?php

use UKCounties\Counties;

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

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