选择国家和城市
是否有包含国家和城市数组的 php 文件,类似于:
$country[] = "Albania";
$country[] = "Algeria";
与城市相同?或者是否有其他可能更好的解决方案来向用户显示国家/地区并让他们选择?谢谢。
Are there php file with array with countries and cities, something like that:
$country[] = "Albania";
$country[] = "Algeria";
And the same with cities? Or are there any other, maybe better, solutions for showing countries for users and give them to select? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,GeoNames:
对于城市,您需要使用边界框坐标(可从之前的请求结果)和 Cities 方法,还支持本地化大多数语言使用
lang
查询字符串。编辑:您可能想要缓存(或下载)这些结果以避免GeoNames 服务器超载。
Yes, GeoNames:
For cities you need to use the bounding box coordinates (available from the previous request result) and the Cities method, localization is also supported for most languages using the
lang
query string.EDIT: You probably want to cache (or download) these results to avoid overloading GeoNames server.
PHP 中没有内置类似的东西。您必须找到一个国家/地区列表,然后使用 PHP 解析它或将其存储在 MySQL 表中。
There isn't something like this built into PHP. You'll have to find a country list and either parse it with PHP or store it in a MySQL table.
如果您不想使用数据库,最好的方法是使用网络服务为您提供列表
例如:这个
Your best approach if you don't want to use a database is to use a webservice to provide you with a list
like: This one
国家/地区
我刚刚从数据库中导出此列表。
关于城市,我无能为力。
Countries
I've just exported this list from my database.
About cities, I can't help.