Revision: 63288
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 23, 2013 02:17 by Concept211
Initial Code
/* Convert State Name/Abbrev/Code Function */ function convertState($strInput, $strFormat='name', $blnDefaultToInput=false) { $arrStates = array( array('code'=>'01', 'abbrev'=>'AL', 'name'=>'Alabama'), array('code'=>'02', 'abbrev'=>'AK', 'name'=>'Alaska'), array('code'=>'04', 'abbrev'=>'AZ', 'name'=>'Arizona'), array('code'=>'05', 'abbrev'=>'AR', 'name'=>'Arkansas'), array('code'=>'06', 'abbrev'=>'CA', 'name'=>'California'), array('code'=>'08', 'abbrev'=>'CO', 'name'=>'Colorado'), array('code'=>'09', 'abbrev'=>'CT', 'name'=>'Connecticut'), array('code'=>'10', 'abbrev'=>'DE', 'name'=>'Delaware'), array('code'=>'11', 'abbrev'=>'DC', 'name'=>'District of Columbia'), array('code'=>'11', 'abbrev'=>'DC', 'name'=>'Washington DC'), array('code'=>'11', 'abbrev'=>'DC', 'name'=>'Washington D.C.'), array('code'=>'12', 'abbrev'=>'FL', 'name'=>'Florida'), array('code'=>'13', 'abbrev'=>'GA', 'name'=>'Georgia'), array('code'=>'15', 'abbrev'=>'HI', 'name'=>'Hawaii'), array('code'=>'16', 'abbrev'=>'ID', 'name'=>'Idaho'), array('code'=>'17', 'abbrev'=>'IL', 'name'=>'Illinois'), array('code'=>'18', 'abbrev'=>'IN', 'name'=>'Indiana'), array('code'=>'19', 'abbrev'=>'IA', 'name'=>'Iowa'), array('code'=>'20', 'abbrev'=>'KS', 'name'=>'Kansas'), array('code'=>'21', 'abbrev'=>'KY', 'name'=>'Kentucky'), array('code'=>'22', 'abbrev'=>'LA', 'name'=>'Louisiana'), array('code'=>'23', 'abbrev'=>'ME', 'name'=>'Maine'), array('code'=>'24', 'abbrev'=>'MD', 'name'=>'Maryland'), array('code'=>'25', 'abbrev'=>'MA', 'name'=>'Massachusetts'), array('code'=>'26', 'abbrev'=>'MI', 'name'=>'Michigan'), array('code'=>'27', 'abbrev'=>'MN', 'name'=>'Minnesota'), array('code'=>'28', 'abbrev'=>'MS', 'name'=>'Mississippi'), array('code'=>'29', 'abbrev'=>'MO', 'name'=>'Missouri'), array('code'=>'30', 'abbrev'=>'MT', 'name'=>'Montana'), array('code'=>'31', 'abbrev'=>'NE', 'name'=>'Nebraska'), array('code'=>'32', 'abbrev'=>'NV', 'name'=>'Nevada'), array('code'=>'33', 'abbrev'=>'NH', 'name'=>'New Hampshire'), array('code'=>'34', 'abbrev'=>'NJ', 'name'=>'New Jersey'), array('code'=>'35', 'abbrev'=>'NM', 'name'=>'New Mexico'), array('code'=>'36', 'abbrev'=>'NY', 'name'=>'New York'), array('code'=>'37', 'abbrev'=>'NC', 'name'=>'North Carolina'), array('code'=>'38', 'abbrev'=>'ND', 'name'=>'North Dakota'), array('code'=>'39', 'abbrev'=>'OH', 'name'=>'Ohio'), array('code'=>'40', 'abbrev'=>'OK', 'name'=>'Oklahoma'), array('code'=>'41', 'abbrev'=>'OR', 'name'=>'Oregon'), array('code'=>'42', 'abbrev'=>'PA', 'name'=>'Pennsylvania'), array('code'=>'44', 'abbrev'=>'RI', 'name'=>'Rhode Island'), array('code'=>'45', 'abbrev'=>'SC', 'name'=>'South Carolina'), array('code'=>'46', 'abbrev'=>'SD', 'name'=>'South Dakota'), array('code'=>'47', 'abbrev'=>'TN', 'name'=>'Tennessee'), array('code'=>'48', 'abbrev'=>'TX', 'name'=>'Texas'), array('code'=>'49', 'abbrev'=>'UT', 'name'=>'Utah'), array('code'=>'50', 'abbrev'=>'VT', 'name'=>'Vermont'), array('code'=>'51', 'abbrev'=>'VA', 'name'=>'Virginia'), array('code'=>'53', 'abbrev'=>'WA', 'name'=>'Washington'), array('code'=>'54', 'abbrev'=>'WV', 'name'=>'West Virginia'), array('code'=>'55', 'abbrev'=>'WI', 'name'=>'Wisconsin'), array('code'=>'56', 'abbrev'=>'WY', 'name'=>'Wyoming'), array('code'=>'60', 'abbrev'=>'AS', 'name'=>'American Samoa'), array('code'=>'66', 'abbrev'=>'GU', 'name'=>'Guam'), array('code'=>'69', 'abbrev'=>'MP', 'name'=>'Northern Mariana Islands'), array('code'=>'72', 'abbrev'=>'PR', 'name'=>'Puerto Rico'), array('code'=>'78', 'abbrev'=>'VI', 'name'=>'Virgin Islands'), array('code'=>'64', 'abbrev'=>'FM', 'name'=>'Federated States of Micronesia'), array('code'=>'68', 'abbrev'=>'MH', 'name'=>'Marshall Islands'), array('code'=>'70', 'abbrev'=>'PW', 'name'=>'Palau') ); $strOutput = ($blnDefaultToInput) ? $strInput : ''; $strFormat = strtolower(trim($strFormat)); foreach ($arrStates as $arrState) { foreach ($arrState as $strValue) { if (strtolower($strValue) == strtolower(trim($strInput))) { if ($strFormat == 'code') { $strOutput = $arrState['code']; } else if ($strFormat == 'abbrev') { $strOutput = $arrState['abbrev']; } else { $strOutput = $arrState['name']; } break; } } } return $strOutput; }
Initial URL
http://concept211.com
Initial Description
State to Name/Abbreviation/Code Conversion Function
Initial Title
State to Name/Abbreviation/Code Conversion Function
Initial Tags
Initial Language
PHP