php 如何在php中列出所有国家及其州/省?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1424993/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to list all countries and its states/provinces in php?
提问by Alix Axel
Is there any quick guide/reference to list all the countries and its states/provinces?
是否有任何快速指南/参考来列出所有国家及其州/省?
Like when I click US, it will list: Alabama, alaska etc
就像当我点击美国时,它会列出:阿拉巴马州、阿拉斯加州等
采纳答案by beggs
回答by Alix Axel
pycountryis the most complete free reference I was ever able to find:
pycountry是我能找到的最完整的免费参考:
pycountry provides the ISO databases for the standards:
639 Languages
3166 Countries
3166-2 Subdivisions of countries
4217 Currencies
15924 Scripts
The databases are imported from Debian's pkg-isocodes, packaged into pycountry and made accessible through a Python API.
Translation files for the various strings are included as well.
回答by squeeks
Grabbing data from Geonameswould be an option. It is kept relatively up to date, and is under a CC license.
从Geonames 获取数据将是一种选择。它保持相对最新,并获得 CC 许可。
回答by Arjan
In case you don't want to use sql, here is just a javascript with region country's province/state, i found it a while ago. Maybe its of good use....
如果您不想使用 sql,这里只是一个带有地区国家/省/州的 javascript,我不久前找到了它。也许它的用处很好......
http://www.sitepoint.com/forums/showthread.php?350291-Country-State-City-Dropdown-list
http://www.sitepoint.com/forums/showthread.php?350291-Country-State-City-Dropdown-list
回答by Yosoyadri
As Squeeks says you can use GeoNames.
正如 Squeeks 所说,您可以使用 GeoNames。
I did a tool ( https://github.com/yosoyadri/GeoNames-XML-Builder) that downloads and saves GeoNames response as a XML file based on the library at http://geonamesdotorgdotnet.codeplex.com/.
我做了一个工具(https://github.com/yosoyadri/GeoNames-XML-Builder),它根据http://geonamesdotorgdotnet.codeplex.com/上的库下载并保存 GeoNames 响应作为 XML 文件。
You can also download a complete file of countries and states/provinces at https://raw.github.com/yosoyadri/GeoNames-XML-Builder/master/continents-countries-statesprovinces.xml
您还可以在https://raw.github.com/yosoyadri/GeoNames-XML-Builder/master/continents-countries-statesprovinces.xml下载完整的国家和州/省文件
回答by randomx
This is as close as it gets. http://27.org/isocountrylist/
这已经很接近了。 http://27.org/isocountrylist/
This list is rather old, however it does offer a great deal of value for those wanting a country list, with codes and abbreviations. Also, there is a link to US States and provinces there too. This has been a good resource over the years.
该列表相当陈旧,但对于那些想要包含代码和缩写的国家/地区列表的人来说,它确实提供了很大的价值。此外,那里也有指向美国各州和省的链接。多年来,这是一个很好的资源。
With this table data, it's possible for someone to create some normalized data between countries, states, provinces, counties or whatever political jurisdictions.
有了这个表数据,有人可以在国家、州、省、县或任何管辖区之间创建一些规范化的数据。
I thought this would be a huge time saver for this task.
我认为这将为这项任务节省大量时间。

