US States and World Countries Collection


/ Published in: PHP

This is a collection of US States (Long and abbreviated names) and world countries. There are a few examples of usage below the collections.


Copy this code and paste it in your HTML
  1. //--------------------------------------------------------------------------------------------------------------------------------------
  2.  
  3. $states_abv_string = 'AL, AK, AZ, AR, CA, CO, CT, DE, FL, GA, HI, ID, IL, IN, IA, KS, KY, LA, ME, MD, MA, MI, MN, MS, MO, MT, NE, NV, NH, NJ, NM, NY, NC, ND, OH, OK, OR, PA, RI, SC, SD, TN, TX, UT, VT, VA, WA, WV, WI, WY';
  4. $states_string = 'Alabama, Alaska, Arizona, Arkansas, California, Colorado, Connecticut, Delaware, Florida, Georgia, Hawaii, Idaho, Illinois, Indiana, Iowa, Kansas, Kentucky, Louisiana, Maine, Maryland, Massachusetts, Michigan, Minnesota, Mississippi, Missouri, Montana, Nebraska, Nevada, New Hampshire, New Jersey, New Mexico, New York, North Carolina, North Dakota, Ohio, Oklahoma, Oregon, Pennsylvania, Rhode Island, South Carolina, South Dakota, Tennessee, Texas, Utah, Vermont, Virginia, Washington, West Virginia, Wisconsin, Wyoming';
  5. $countries_string = 'Afghanistan, Albania, Algeria, Andorra, Angola, Antigua and Barbuda, Argentina, Armenia, Australia, Austria, Azerbaijan, Bahamas, Bahrain, Bangladesh, Barbados, Belarus, Belgium, Belize, Benin, Bhutan, Bolivia, Bosnia and Herzegovina, Botswana, Brazil, Brunei Darussalam, Bulgaria, Burkina Faso, Burma, Burundi, Cambodia, Cameroon, Canada, Cape Verde, Central African Republic, Chad, Chile, China, Colombia, Comoros, Congo, Democratic Republic of the Congo, Costa Rica, Côte d\'Ivoire, Croatia, Cuba, Cyprus, Czech Republic, Denmark, Djibouti, Dominica, Dominican Republic, East Timor, Ecuador, Egypt, El Salvador, England, Equatorial Guinea, Eritrea, Estonia, Ethiopia, Fiji, Finland, France, Gabon, Gambia, Georgia, Germany, Ghana, Great Britain, Greece, Grenada, Guatemala, Guinea, Guinea-Bissau, Guyana, Haiti, Honduras, Hungary, Iceland, India, Indonesia, Iran, Iraq, Ireland, Israel, Italy, Jamaica, Japan, Jordan, Kazakhstan, Kenya, Kiribati, North Korea, South Korea, Kuwait, Kyrgyzstan, Laos, Latvia, Lebanon, Lesotho, Liberia, Libya, Liechtenstein, Lithuania, Luxembourg, Macedonia, Madagascar, Malawi, Malaysia, Maldives, Mali, Malta, Marshall Islands, Mauritania, Mauritius, Mexico, Micronesia, Moldova, Monaco, Mongolia, Morocco, Mozambique, Myanmar, Namibia, Nauru, Nepal, The Netherlands, New Zealand, Nicaragua, Niger, Nigeria, Northern Ireland, Norway, Oman, Pakistan, Palau, Palestinian State, Panama, Papua New Guinea, Paraguay, Peru, The Philippines, Poland, Portugal, Qatar, Romania, Russia, Rwanda, St. Kitts and Nevis, St. Lucia, St. Vincent and The Grenadines, Samoa, San Marino, São Tomé and Príncipe, Saudi Arabia, Scotland, Senegal, Serbia and Montenegro, Seychelles, Sierra Leone, Singapore, Slovakia, Slovenia, Solomon Islands, Somalia, South Africa, Spain, Sri Lanka, Sudan, Suriname, Swaziland, Sweden, Switzerland, Syria, Taiwan, Tajikistan, Tanzania, Thailand, Togo, Tonga, Trinidad and Tobago, Tunisia, Turkey, Turkmenistan, Tuvalu, Uganda, Ukraine, United Arab Emirates, United Kingdom, United States, Uruguay, Uzbekistan, Vanuatu, Vatican City, Venezuela, Vietnam, Wales, Western Sahara, Yemen, Yugoslavia, Zaire, Zambia';
  6.  
  7. //--------------------------------------------------------------------------------------------------------------------------------------
  8.  
  9. $state_list = 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');
  10.  
  11. //--------------------------------------------------------------------------------------------------------------------------------------
  12.  
  13. $states = explode(', ', $states_abv_string);
  14. sort($states);
  15.  
  16. print('<select name="states">' . "\r\n");
  17. for ($i = 0; $i < count($states); $i++) { print('<option value="' . $states[$i] . '">' . $states[$i] . '</option>' . "\r\n"); }
  18. print('</select>' . "\r\n");
  19.  
  20. //--------------------------------------------------------------------------------------------------------------------------------------
  21.  
  22. $states = explode(', ', $states_string);
  23. sort($states);
  24.  
  25. print('<select name="states">' . "\r\n");
  26. for ($i = 0; $i < count($states); $i++) { print('<option value="' . $states[$i] . '">' . $states[$i] . '</option>' . "\r\n"); }
  27. print('</select>' . "\r\n");
  28.  
  29. //--------------------------------------------------------------------------------------------------------------------------------------
  30.  
  31. $countries = explode(', ', $countries_string);
  32. sort($countries);
  33.  
  34. print('<select name="countries">' . "\r\n");
  35. for ($i = 0; $i < count($countries); $i++) { print('<option value="' . $countries[$i] . '">' . $countries[$i] . '</option>' . "\r\n"); }
  36. print('</select>' . "\r\n");
  37.  
  38. //--------------------------------------------------------------------------------------------------------------------------------------

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.