Array List with U.S. States
Created: Last updated:
US states list
So, you need a php array list with all the US states? Right on, I have the list ready for you in a php array and even as a static method you can add to a class object.
If you click the following link you will get a simple txt document with the US states list. This makes it real easy for you to copy/past the list into your PHP project. You can see how the array in the link will look like below.
If you like to read why I have this copy/paste list then see below. Actually it is more about search engines. Without it they would not index this page. That's how SEO works, I guess.
PHP Array
I have this page and list because I had a problem and maybe you have a similar problem.
You work with the Zend Framework (or another CMS like Wordpress, Joomla or just a plain PHP project). You project requires a form with a select element where users can select the US state they live in. Therefore, you need this: a PHP array with the United States (US).
If you work with the Zend Framework you might think there is a solution with Zend_Locale, just like the one for the country list. Unfortunately there is none and revert to Google to find either a list or some array ready for copy/pase.
Hence, I was looking for an array (not just a list) ready with all these United States in America (USA). What I found was web pages with all sorts of lists but a page where you can easily copy/paste a ready to go PHP array with all states? Not one that exactly had what I was looking for. Most of them were not properly formatted or even worse behind lots and lots of annoying ads and other garbage.
So I create this page with the US-States.txt document. I contains all the United States of America in an array, in case you need one as simple as that.
I have even included the whole array as a static function. You can paste the function into a class as a method. It sports an argument for retrieving just one single state with the abbreviation.
If you are looking for the array on this page here it is below. Although, I highly recommend the txt document above—it is way better for copy/paste.
- // a simple PHP array for copy/paste
- $usStates = array(
'AL' => 'Alabama',
'AK' => 'Alaska',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
'DE' => 'Delaware',
'FL' => 'Florida',
'GA' => 'Georgia',
'HI' => 'Hawaii',
'ID' => 'Idaho',
'IL' => 'Illinois',
'IN' => 'Indiana',
'IA' => 'Iowa',
'KS' => 'Kansas',
'KY' => 'Kentucky',
'LA' => 'Louisiana',
'ME' => 'Maine',
'MD' => 'Maryland',
'MA' => 'Massachusetts',
'MI' => 'Michigan',
'MN' => 'Minnesota',
'MS' => 'Mississippi',
'MO' => 'Missouri',
'MT' => 'Montana',
'NE' => 'Nebraska',
'NV' => 'Nevada',
'NH' => 'New Hampshire',
'NJ' => 'New Jersey',
'NM' => 'New Mexico',
'NY' => 'New York',
'NC' => 'North Carolina',
'ND' => 'North Dakota',
'OH' => 'Ohio',
'OK' => 'Oklahoma',
'OR' => 'Oregon',
'PA' => 'Pennsylvania',
'RI' => 'Rhode Island',
'SC' => 'South Carolina',
'SD' => 'South Dakota',
'TN' => 'Tennessee',
'TX' => 'Texas',
'UT' => 'Utah',
'VT' => 'Vermont',
'VA' => 'Virginia',
'WA' => 'Washington',
'WV' => 'West Virginia',
'WI' => 'Wisconsin',
'WY' => 'Wyoming',
);