Friday, 10 August 2018

PHP Array Of States


Use the following array to print out a list of Canadian states, also know as provinces.
  1. $canadian_states = array(
  2. "BC" => "British Columbia",
  3. "ON" => "Ontario",
  4. "NL" => "Newfoundland and Labrador",
  5. "NS" => "Nova Scotia",
  6. "PE" => "Prince Edward Island",
  7. "NB" => "New Brunswick",
  8. "QC" => "Quebec",
  9. "MB" => "Manitoba",
  10. "SK" => "Saskatchewan",
  11. "AB" => "Alberta",
  12. "NT" => "Northwest Territories",
  13. "NU" => "Nunavut",
  14. "YT" => "Yukon Territory"
  15. );
Here is the same array, but with the French versions of the states.
  1. $canadian_states = array(
  2. "AB" => "Alberta",
  3. "BC" => "Colombie-Britannique",
  4. "MB" => "Manitoba",
  5. "NB" => "Nouveau-Brunswick",
  6. "NL" => "Terre-Neuve-et-Labrador",
  7. "NS" => "Nouvelle-Écosse",
  8. "NT" => "Territoires du Nord-Ouest",
  9. "NU" => "Nunavut",
  10. "ON" => "Ontario",
  11. "PE" => "Île-du-Prince-Édouard",
  12. "QC" => "Québec",
  13. "SK" => "Saskatchewan",
  14. "YT" => "Yukon"
  15. );
Use the following array if you want to print out a list of USA states either as a list, or as a select box.
  1. $state_list = array('AL'=>"Alabama",
  2. 'AK'=>"Alaska",
  3. 'AZ'=>"Arizona",
  4. 'AR'=>"Arkansas",
  5. 'CA'=>"California",
  6. 'CO'=>"Colorado",
  7. 'CT'=>"Connecticut",
  8. 'DE'=>"Delaware",
  9. 'DC'=>"District Of Columbia",
  10. 'FL'=>"Florida",
  11. 'GA'=>"Georgia",
  12. 'HI'=>"Hawaii",
  13. 'ID'=>"Idaho",
  14. 'IL'=>"Illinois",
  15. 'IN'=>"Indiana",
  16. 'IA'=>"Iowa",
  17. 'KS'=>"Kansas",
  18. 'KY'=>"Kentucky",
  19. 'LA'=>"Louisiana",
  20. 'ME'=>"Maine",
  21. 'MD'=>"Maryland",
  22. 'MA'=>"Massachusetts",
  23. 'MI'=>"Michigan",
  24. 'MN'=>"Minnesota",
  25. 'MS'=>"Mississippi",
  26. 'MO'=>"Missouri",
  27. 'MT'=>"Montana",
  28. 'NE'=>"Nebraska",
  29. 'NV'=>"Nevada",
  30. 'NH'=>"New Hampshire",
  31. 'NJ'=>"New Jersey",
  32. 'NM'=>"New Mexico",
  33. 'NY'=>"New York",
  34. 'NC'=>"North Carolina",
  35. 'ND'=>"North Dakota",
  36. 'OH'=>"Ohio",
  37. 'OK'=>"Oklahoma",
  38. 'OR'=>"Oregon",
  39. 'PA'=>"Pennsylvania",
  40. 'RI'=>"Rhode Island",
  41. 'SC'=>"South Carolina",
  42. 'SD'=>"South Dakota",
  43. 'TN'=>"Tennessee",
  44. 'TX'=>"Texas",
  45. 'UT'=>"Utah",
  46. 'VT'=>"Vermont",
  47. 'VA'=>"Virginia",
  48. 'WA'=>"Washington",
  49. 'WV'=>"West Virginia",
  50. 'WI'=>"Wisconsin",
  51. 'WY'=>"Wyoming");
If you want to reverse this then use the following code.
  1. $reverse = array();
  2. foreach ( $state_list as $key=>$state ) {
  3. $reverse[$state] = $key;
  4. }
  5. $state_list = $reverse;

PHP Array Of UK Counties

Use the following code to create an array of counties in the UK.
  1. $counties = array("Aberdeenshire"=>"Aberdeenshire","Angus/Forfarshire"=>"Angus/Forfarshire","Argyllshire"=>"Argyllshire",
  2. "Ayrshire"=>"Ayrshire","Banffshire"=>"Banffshire","Bedfordshire"=>"Bedfordshire","Berkshire"=>"Berkshire",
  3. "Berwickshire"=>"Berwickshire","Blaenau Gwent"=>"Blaenau Gwent","Bridgend"=>"Bridgend",
  4. "Buckinghamshire"=>"Buckinghamshire","Buteshire"=>"Buteshire","Caerphilly"=>"Caerphilly","Caithness"=>"Caithness",
  5. "Cambridgeshire"=>"Cambridgeshire","Cardiff"=>"Cardiff","Carmarthenshire"=>"Carmarthenshire",
  6. "Ceredigion"=>"Ceredigion","Cheshire"=>"Cheshire","Clackmannanshire"=>"Clackmannanshire",
  7. "Conwy"=>"Conwy","Cornwall"=>"Cornwall","Cromartyshire"=>"Cromartyshire","Cumberland"=>"Cumberland",
  8. "Denbighshire"=>"Denbighshire","Derbyshire"=>"Derbyshire","Devon"=>"Devon","Dorset"=>"Dorset",
  9. "Dumfriesshire"=>"Dumfriesshire","Dunbartonshire/Dumbartonshire"=>"Dunbartonshire/Dumbartonshire",
  10. "Durham"=>"Durham","East Lothian/Haddingtonshire"=>"East Lothian/Haddingtonshire","Essex"=>"Essex","Fife"=>"Fife",
  11. "Flintshire"=>"Flintshire","Gloucestershire"=>"Gloucestershire","Gwynedd"=>"Gwynedd","Hampshire"=>"Hampshire",
  12. "Herefordshire"=>"Herefordshire","Hertfordshire"=>"Hertfordshire","Huntingdonshire"=>"Huntingdonshire",
  13. "Inverness-shire"=>"Inverness-shire","Isle of Anglesey"=>"Isle of Anglesey","Kent"=>"Kent",
  14. "Kincardineshire"=>"Kincardineshire","Kinross-shire"=>"Kinross-shire","Kirkcudbrightshire"=>"Kirkcudbrightshire",
  15. "Lanarkshire"=>"Lanarkshire","Lancashire"=>"Lancashire","Leicestershire"=>"Leicestershire",
  16. "Lincolnshire"=>"Lincolnshire","Merthyr Tydfil"=>"Merthyr Tydfil","Middlesex"=>"Middlesex",
  17. "Midlothian/Edinburghshire"=>"Midlothian/Edinburghshire","Monmouthshire"=>"Monmouthshire",
  18. "Morayshire"=>"Morayshire","Nairnshire"=>"Nairnshire","Neath Port Talbot"=>"Neath Port Talbot",
  19. "Newport"=>"Newport","Norfolk"=>"Norfolk","Northamptonshire"=>"Northamptonshire",
  20. "Northumberland"=>"Northumberland","Nottinghamshire"=>"Nottinghamshire","Orkney"=>"Orkney",
  21. "Oxfordshire"=>"Oxfordshire","Peeblesshire"=>"Peeblesshire","Pembrokeshire"=>"Pembrokeshire",
  22. "Perthshire"=>"Perthshire","Powys"=>"Powys","Renfrewshire"=>"Renfrewshire",
  23. "Rhondda Cynon Taff"=>"Rhondda Cynon Taff","Ross-shire"=>"Ross-shire","Roxburghshire"=>"Roxburghshire",
  24. "Rutland"=>"Rutland","Selkirkshire"=>"Selkirkshire","Shetland"=>"Shetland","Shropshire"=>"Shropshire",
  25. "Somerset"=>"Somerset","Staffordshire"=>"Staffordshire","Stirlingshire"=>"Stirlingshire","Suffolk"=>"Suffolk",
  26. "Surrey"=>"Surrey","Sussex"=>"Sussex","Sutherland"=>"Sutherland","Swansea"=>"Swansea","Torfaen"=>"Torfaen","Tyne and Wear"=>"Tyne and Wear",
  27. "Vale of Glamorgan"=>"Vale of Glamorgan","Warwickshire"=>"Warwickshire",
  28. "West Lothian/Linlithgowshire"=>"West Lothian/Linlithgowshire","Westmorland"=>"Westmorland",
  29. "Wigtownshire"=>"Wigtownshire","Wiltshire"=>"Wiltshire",
  30. "Worcestershire"=>"Worcestershire","Wrexham"=>"Wrexham","Yorkshire"=>"Yorkshire");
This can be used to create a list of counties for a form.
Use the following array to print out a list of Australian states.
  1. $australian_states = array(
  2. "NSW"=>"New South Wales",
  3. "VIC"=>"Victoria",
  4. "QLD"=>"Queensland",
  5. "TAS"=>"Tasmania",
  6. "SA"=>"South Australia",
  7. "WA"=>"Western Australia",
  8. "NT"=>"Northern Territory",
  9. "ACT"=>"Australian Capital Terrirory");

0 comments:

Post a Comment