Skip to content

Instantly share code, notes, and snippets.

@jeskew
Forked from mshafrir/states_hash.json
Last active August 29, 2015 13:56
Show Gist options
  • Save jeskew/8977626 to your computer and use it in GitHub Desktop.
Save jeskew/8977626 to your computer and use it in GitHub Desktop.
<?php
namespace Libraries\Abbreviations;
class States
{
public static function getTitleCase()
{
$titleCaseHash = array();
foreach (self::getHash() as $name => $abbreviation) {
$titleCaseHash []= array(
'name' => $name,
'abbreviation' => $abbreviation
);
}
return $titleCaseHash;
}
public static function getAbbrToNameHash()
{
return self::getHash();
}
public static function getNameToAbbrHash()
{
return array_flip(self::getHash());
}
public static function getHash()
{
return array(
'AL' => 'Alabama',
'AK' => 'Alaska',
'AS' => 'American Samoa',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
'DE' => 'Delaware',
'DC' => 'District Of Columbia',
'FM' => 'Federated States Of Micronesia',
'FL' => 'Florida',
'GA' => 'Georgia',
'GU' => 'Guam',
'HI' => 'Hawaii',
'ID' => 'Idaho',
'IL' => 'Illinois',
'IN' => 'Indiana',
'IA' => 'Iowa',
'KS' => 'Kansas',
'KY' => 'Kentucky',
'LA' => 'Louisiana',
'ME' => 'Maine',
'MH' => 'Marshall Islands',
'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',
'MP' => 'Northern Mariana Islands',
'OH' => 'Ohio',
'OK' => 'Oklahoma',
'OR' => 'Oregon',
'PW' => 'Palau',
'PA' => 'Pennsylvania',
'PR' => 'Puerto Rico',
'RI' => 'Rhode Island',
'SC' => 'South Carolina',
'SD' => 'South Dakota',
'TN' => 'Tennessee',
'TX' => 'Texas',
'UT' => 'Utah',
'VT' => 'Vermont',
'VI' => 'Virgin Islands',
'VA' => 'Virginia',
'WA' => 'Washington',
'WV' => 'West Virginia',
'WI' => 'Wisconsin',
'WY' => 'Wyoming',
);
}
}
<?php
return array(
'AL' => 'Alabama',
'AK' => 'Alaska',
'AS' => 'American Samoa',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
'DE' => 'Delaware',
'DC' => 'District Of Columbia',
'FM' => 'Federated States Of Micronesia',
'FL' => 'Florida',
'GA' => 'Georgia',
'GU' => 'Guam',
'HI' => 'Hawaii',
'ID' => 'Idaho',
'IL' => 'Illinois',
'IN' => 'Indiana',
'IA' => 'Iowa',
'KS' => 'Kansas',
'KY' => 'Kentucky',
'LA' => 'Louisiana',
'ME' => 'Maine',
'MH' => 'Marshall Islands',
'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',
'MP' => 'Northern Mariana Islands',
'OH' => 'Ohio',
'OK' => 'Oklahoma',
'OR' => 'Oregon',
'PW' => 'Palau',
'PA' => 'Pennsylvania',
'PR' => 'Puerto Rico',
'RI' => 'Rhode Island',
'SC' => 'South Carolina',
'SD' => 'South Dakota',
'TN' => 'Tennessee',
'TX' => 'Texas',
'UT' => 'Utah',
'VT' => 'Vermont',
'VI' => 'Virgin Islands',
'VA' => 'Virginia',
'WA' => 'Washington',
'WV' => 'West Virginia',
'WI' => 'Wisconsin',
'WY' => 'Wyoming',
);
<?php
return array(
array(
'name' => 'Alabama',
'abbreviation' => 'AL'
),
array(
'name' => 'Alaska',
'abbreviation' => 'AK'
),
array(
'name' => 'American Samoa',
'abbreviation' => 'AS'
),
array(
'name' => 'Arizona',
'abbreviation' => 'AZ'
),
array(
'name' => 'Arkansas',
'abbreviation' => 'AR'
),
array(
'name' => 'California',
'abbreviation' => 'CA'
),
array(
'name' => 'Colorado',
'abbreviation' => 'CO'
),
array(
'name' => 'Connecticut',
'abbreviation' => 'CT'
),
array(
'name' => 'Delaware',
'abbreviation' => 'DE'
),
array(
'name' => 'District Of Columbia',
'abbreviation' => 'DC'
),
array(
'name' => 'Federated States Of Micronesia',
'abbreviation' => 'FM'
),
array(
'name' => 'Florida',
'abbreviation' => 'FL'
),
array(
'name' => 'Georgia',
'abbreviation' => 'GA'
),
array(
'name' => 'Guam',
'abbreviation' => 'GU'
),
array(
'name' => 'Hawaii',
'abbreviation' => 'HI'
),
array(
'name' => 'Idaho',
'abbreviation' => 'ID'
),
array(
'name' => 'Illinois',
'abbreviation' => 'IL'
),
array(
'name' => 'Indiana',
'abbreviation' => 'IN'
),
array(
'name' => 'Iowa',
'abbreviation' => 'IA'
),
array(
'name' => 'Kansas',
'abbreviation' => 'KS'
),
array(
'name' => 'Kentucky',
'abbreviation' => 'KY'
),
array(
'name' => 'Louisiana',
'abbreviation' => 'LA'
),
array(
'name' => 'Maine',
'abbreviation' => 'ME'
),
array(
'name' => 'Marshall Islands',
'abbreviation' => 'MH'
),
array(
'name' => 'Maryland',
'abbreviation' => 'MD'
),
array(
'name' => 'Massachusetts',
'abbreviation' => 'MA'
),
array(
'name' => 'Michigan',
'abbreviation' => 'MI'
),
array(
'name' => 'Minnesota',
'abbreviation' => 'MN'
),
array(
'name' => 'Mississippi',
'abbreviation' => 'MS'
),
array(
'name' => 'Missouri',
'abbreviation' => 'MO'
),
array(
'name' => 'Montana',
'abbreviation' => 'MT'
),
array(
'name' => 'Nebraska',
'abbreviation' => 'NE'
),
array(
'name' => 'Nevada',
'abbreviation' => 'NV'
),
array(
'name' => 'New Hampshire',
'abbreviation' => 'NH'
),
array(
'name' => 'New Jersey',
'abbreviation' => 'NJ'
),
array(
'name' => 'New Mexico',
'abbreviation' => 'NM'
),
array(
'name' => 'New York',
'abbreviation' => 'NY'
),
array(
'name' => 'North Carolina',
'abbreviation' => 'NC'
),
array(
'name' => 'North Dakota',
'abbreviation' => 'ND'
),
array(
'name' => 'Northern Mariana Islands',
'abbreviation' => 'MP'
),
array(
'name' => 'Ohio',
'abbreviation' => 'OH'
),
array(
'name' => 'Oklahoma',
'abbreviation' => 'OK'
),
array(
'name' => 'Oregon',
'abbreviation' => 'OR'
),
array(
'name' => 'Palau',
'abbreviation' => 'PW'
),
array(
'name' => 'Pennsylvania',
'abbreviation' => 'PA'
),
array(
'name' => 'Puerto Rico',
'abbreviation' => 'PR'
),
array(
'name' => 'Rhode Island',
'abbreviation' => 'RI'
),
array(
'name' => 'South Carolina',
'abbreviation' => 'SC'
),
array(
'name' => 'South Dakota',
'abbreviation' => 'SD'
),
array(
'name' => 'Tennessee',
'abbreviation' => 'TN'
),
array(
'name' => 'Texas',
'abbreviation' => 'TX'
),
array(
'name' => 'Utah',
'abbreviation' => 'UT'
),
array(
'name' => 'Vermont',
'abbreviation' => 'VT'
),
array(
'name' => 'Virgin Islands',
'abbreviation' => 'VI'
),
array(
'name' => 'Virginia',
'abbreviation' => 'VA'
),
array(
'name' => 'Washington',
'abbreviation' => 'WA'
),
array(
'name' => 'West Virginia',
'abbreviation' => 'WV'
),
array(
'name' => 'Wisconsin',
'abbreviation' => 'WI'
),
array(
'name' => 'Wyoming',
'abbreviation' => 'WY'
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment