How to list all countries and their states / provinces in php?

Is there any short guide / link to list all countries and its states / provinces?

Like when I press US, it will list: Alabama, Alaska, etc.

+6
list php
source share
6 answers

I don't have a code for this, but if you need a good (free) list of administrative districts for most of the world, you can use this page on Wikipedia.

+3
source share

pycountry is the most complete free link I could ever find:

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 pkg-isocodes, packaged into pycountry and made accessible through a Python API. Translation files for the various strings are included as well. 
+8
source share

Take the data from Geonames . It is maintained relatively modern and is licensed under CC.

+4
source share

If you do not want to use sql, here is just javascript with a country / state region, I found it a while ago. Perhaps this is useful ...

http://www.sitepoint.com/forums/showthread.php?350291-Country-State-City-Dropdown-list

+1
source share

As Squeeks says, you can use GeoNames.

I made a tool ( https://github.com/yosoyadri/GeoNames-XML-Builder ) that downloads and saves the GeoNames response as an XML based library file at http://geonamesdotorgdotnet.codeplex.com/ .

You can also download the full file of countries and states / provinces at https://raw.github.com/yosoyadri/GeoNames-XML-Builder/master/continents-countries-statesprovinces.xml

+1
source share

It is as close as possible. http://27.org/isocountrylist/

This list is quite old, but it offers great value for those who want to get a list of countries, with codes and abbreviations. In addition, there is a connection with the United States and provinces. Over the years, it has been a good resource.

Using this data table for someone, you can create some normalized data between countries, states, provinces, counties or any political jurisdictions.

I thought it would be a huge time saver for this task.

-one
source share

All Articles