PHP Array Of USA States

Use the following array if you want to print out a list of USA states either as a list, or as a select box.

$state_list = array('AL'=>"Alabama",  
    'DC'=>"District Of Columbia",  
    'NH'=>"New Hampshire",
    'NJ'=>"New Jersey",
    'NM'=>"New Mexico",
    'NY'=>"New York",
    'NC'=>"North Carolina",
    'ND'=>"North Dakota",
    'RI'=>"Rhode Island",  
    'SC'=>"South Carolina",  
    'SD'=>"South Dakota",
    'WV'=>"West Virginia",  

If you want to reverse this then use the following code.

$reverse = array();
foreach ( $state_list as $key=>$state ) {
    $reverse[$state] = $key;
$state_list = $reverse;


Just a note: the correct way to reverse the array would be as follows:
$state_list = array_reverse($state_list,true);
The second argument is important: if you don't include it, the array will be re-indexed with numeric keys instead of the state abbreviations.
great post

Add new comment

The content of this field is kept private and will not be shown publicly.
6 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.