开发者

PHP API for locating continent by state or country

Is there an API that can be used for locating continents? We have in our database only part of the countries plus the continents. We want to be able to match given country or state(for example Texas) and to get the continent as a result(for the example Texas is not in our database).

Can be Google API be used for this or any other ideas?

The implementations will 开发者_StackOverflowbe coded in PHP + MySQL.


I don't how this fits into your existing project but you can use Zend_Locale. It has basically everything you need in terms of countries and regions, like continents (not sub divisions like US States, though). There is no function doing exactly what you are asking but you can easily extend the main class and add such a function.

As a shameless plug, I have written two tutorials about country lists in Zend_Locale and even a dedicated country-list web site to get lists in various formats directly from Zend_Locale. The link to my Country List Project should get you started. As a site note and teaser about sub divisions like US States: I'm currently working on a project extending Zend_Locale so it can handle sub divisions.


As said in the comment, I wouldn't use an API for this, but manually add the contintent information based e.g. on Wikipedia's List of sovereign states and dependent territories by continent.

Creating an API dependency for this kind of info that will change extremely rarely (like when countries fall apart, or are created) feels unnecessary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜