PHP States Array

Today a co-worker of mind asked me if I had an array of states handy so he didn't have to go create one. I did, and gave it to him, and thought that maybe someone else could benefit from it. So, continue on to get a copy/paste PHP array of states.

  1. $statesFull = array(
  2. "AL" => "Alabama",
  3. "AK" => "Alaska",
  4. "AZ" => "Arizona",
  5. "AR" => "Arkansas",
  6. "CA" => "California",
  7. "CO" => "Colorado",
  8. "CT" => "Connecticut",
  9. "DE" => "Delaware",
  10. "DC" => "Washington DC",
  11. "FL" => "Florida",
  12. "GA" => "Georgia",
  13. "HI" => "Hawaii",
  14. "ID" => "Idaho",
  15. "IL" => "Illinois",
  16. "IN" => "Indiana",
  17. "IA" => "Iowa",
  18. "KS" => "Kansas",
  19. "KY" => "Kentucky",
  20. "LA" => "Louisiana",
  21. "ME" => "Maine",
  22. "MD" => "Maryland",
  23. "MA" => "Massachusetts",
  24. "MI" => "Michigan",
  25. "MN" => "Minnesota",
  26. "MS" => "Mississippi",
  27. "MO" => "Missouri",
  28. "MT" => "Montana",
  29. "NE" => "Nebraska",
  30. "NV" => "Nevada",
  31. "NH" => "New Hampshire",
  32. "NJ" => "New Jersey",
  33. "NM" => "New Mexico",
  34. "NY" => "New York",
  35. "NC" => "North Carolina",
  36. "ND" => "North Dakota",
  37. "OH" => "Ohio",
  38. "OK" => "Oklahoma",
  39. "OR" => "Oregon",
  40. "PA" => "Pennsylvania",
  41. "RI" => "Rhode Island",
  42. "SC" => "South Carolina",
  43. "SD" => "South Dakota",
  44. "TN" => "Tennessee",
  45. "TX" => "Texas",
  46. "UT" => "Utah",
  47. "VT" => "Vermont",
  48. "VA" => "Virginia",
  49. "WA" => "Washington",
  50. "WV" => "West Virginia",
  51. "WI" => "Wisconsin",
  52. "WY" => "Wyoming",
  53. );
  54. $statesShort = array_keys($statesFull);
  55. $statesLong = array_values($statesFull);

There ya go :-)

As a side note, I have noticed that search engines like it more when you make pulldown menus for state choices that have the display value of each state in the form of "KY - Kentucky", regardless of what the option value is.

 

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

Comments

Thank you!

Leave a comment

(required)

(required)