RE: [PHP] simplify if/then statement
| From: | Miguel Cruz | Date: | Sat, 27 Apr 2002 18:57:43 +0000 |
| Subject: | RE: [PHP] simplify if/then statement | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-94934@lists.php.net to get a copy of this message | ||
On Sat, 27 Apr 2002, Philip Olson wrote:
> I'd do something similar to this, along with putting all states in an
> array to make sure $state is actually a state (in_array). And maybe you
> want to add guam :)
As an early Christmas present, here's the array (to save the OP some
typing - I'm posting this to the list because I use it a lot and assume
it'd be handy for others too). Uses USPS 2-letter abbreviations and
includes territories.
$states = array(
'AK' => 'Alaska',
'AL' => 'Alabama',
'AR' => 'Arkansas',
'AS' => 'American Samoa',
'AZ' => 'Arizona',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
'DC' => 'District of Columbia',
'DE' => 'Delaware',
'FL' => 'Florida',
'GA' => 'Georgia',
'GU' => 'Guam',
'HI' => 'Hawaii',
'IA' => 'Iowa',
'ID' => 'Idaho',
'IL' => 'Illinois',
'IN' => 'Indiana',
'KS' => 'Kansas',
'KY' => 'Kentucky',
'LA' => 'Louisiana',
'MA' => 'Massachusetts',
'MD' => 'Maryland',
'ME' => 'Maine',
'MH' => 'Marshall Islands',
'MI' => 'Michigan',
'MN' => 'Minnesota',
'MO' => 'Missouri',
'MP' => 'Northern Mariana Islands',
'MS' => 'Mississippi',
'MT' => 'Montana',
'NC' => 'North Carolina',
'ND' => 'North Dakota',
'NE' => 'Nebraska',
'NH' => 'New Hampshire',
'NJ' => 'New Jersey',
'NM' => 'New Mexico',
'NV' => 'Nevada',
'NY' => 'New York',
'OH' => 'Ohio',
'OK' => 'Oklahoma',
'OR' => 'Oregon',
'PA' => 'Pennsylvania',
'PR' => 'Puerto Rico',
'RI' => 'Rhode Island',
'SC' => 'South Carolina',
'SD' => 'South Dakota',
'TN' => 'Tennessee',
'TX' => 'Texas',
'UT' => 'Utah',
'VA' => 'Virginia',
'VI' => 'Virgin Islands (U.S.)',
'VT' => 'Vermont',
'WA' => 'Washington',
'WI' => 'Wisconsin',
'WV' => 'West Virginia',
'WY' => 'Wyoming');
miguel