Yogesh Chauhan's Blog

PHP arrays for US states’ full names and abbreviations

in PHP on June 4, 2020

US States abbreviations to Full Name


$states = array(
            'AL' => 'Alabama',
            'AK' => 'Alaska',
            'AZ' => 'Arizona',
            'AR' => 'Arkansas',
            'CA' => 'California',
            'CO' => 'Colorado',
            'CT' => 'Connecticut',
            'DE' => 'Delaware',
            'DC' => 'Washington DC',
            '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',
            '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',
        );

US States Full Names to abbreviations


$states = array(
'Alabama'=>'AL',
'Alaska'=>'AK',
'Arizona'=>'AZ',
'Arkansas'=>'AR',
'California'=>'CA',
'Colorado'=>'CO',
'Connecticut'=>'CT',
'Delaware'=>'DE',
'Florida'=>'FL',
'Georgia'=>'GA',
'Hawaii'=>'HI',
'Idaho'=>'ID',
'Illinois'=>'IL',
'Indiana'=>'IN',
'Iowa'=>'IA',
'Kansas'=>'KS',
'Kentucky'=>'KY',
'Louisiana'=>'LA',
'Maine'=>'ME',
'Maryland'=>'MD',
'Massachusetts'=>'MA',
'Michigan'=>'MI',
'Minnesota'=>'MN',
'Mississippi'=>'MS',
'Missouri'=>'MO',
'Montana'=>'MT',
'Nebraska'=>'NE',
'Nevada'=>'NV',
'New Hampshire'=>'NH',
'New Jersey'=>'NJ',
'New Mexico'=>'NM',
'New York'=>'NY',
'North Carolina'=>'NC',
'North Dakota'=>'ND',
'Ohio'=>'OH',
'Oklahoma'=>'OK',
'Oregon'=>'OR',
'Pennsylvania'=>'PA',
'Rhode Island'=>'RI',
'South Carolina'=>'SC',
'South Dakota'=>'SD',
'Tennessee'=>'TN',
'Texas'=>'TX',
'Utah'=>'UT',
'Vermont'=>'VT',
'Virginia'=>'VA',
'Washington'=>'WA',
'West Virginia'=>'WV',
'Wisconsin'=>'WI',
'Wyoming'=>'WY'
);

For Google Maps or other Maps API, use this latitudes and longitudes for states


$statesCoord = array(
        'AL'=>'32.6010112,-86.6807365',
        'AK'=>'61.3025006,-158.7750198',
        'AZ'=>'34.1682185,-111.930907',
        'AR'=>'34.7519275,-92.1313784',
        'CA'=>'37.2718745,-119.2704153',
        'CO'=>'38.9979339,-105.550567',
        'CT'=>'41.5187835,-72.757507',
        'DE'=>'39.145251,-75.4189206',
        'DC'=>'38.8993487,-77.0145666',
        'FL'=>'27.9757279,-83.8330166',
        'GA'=>'32.6781248,-83.2229757',
        'HI'=>'20.46,-157.505',
        'ID'=>'45.4945756,-114.1424303',
        'IL'=>'39.739318,-89.504139',
        'IN'=>'39.7662195,-86.441277',
        'IA'=>'41.9383166,-93.389798',
        'KS'=>'38.4987789,-98.3200779',
        'KY'=>'37.8222935,-85.7682399',
        'LA'=>'30.9733766,-91.4299097',
        'ME'=>'45.2185133,-69.0148656',
        'MD'=>'38.8063524,-77.2684162',
        'MA'=>'42.0629398,-71.718067',
        'MI'=>'44.9435598,-86.4158049',
        'MN'=>'46.4418595,-93.3655146',
        'MS'=>'32.5851062,-89.8772196',
        'MO'=>'38.3046615,-92.437099',
        'MT'=>'46.6797995,-110.044783',
        'NE'=>'41.5008195,-99.680902',
        'NV'=>'38.502032,-117.0230604',
        'NH'=>'44.0012306,-71.5799231',
        'NJ'=>'40.1430058,-74.7311156',
        'NM'=>'34.1662325,-106.0260685',
        'NY'=>'40.7056258,-73.97968',
        'NC'=>'35.2145629,-79.8912675',
        'ND'=>'47.4678819,-100.3022655',
        'OH'=>'40.1903624,-82.6692525',
        'OK'=>'35.3097654,-98.7165585',
        'OR'=>'44.1419049,-120.5380993',
        'PA'=>'40.9945928,-77.6046984',
        'RI'=>'41.5827282,-71.5064508',
        'SC'=>'33.62505,-80.9470381',
        'SD'=>'44.2126995,-100.2471641',
        'TN'=>'35.830521,-85.9785989',
        'TX'=>'31.1693363,-100.0768425',
        'UT'=>'39.4997605,-111.547028',
        'VT'=>'43.8717545,-72.4477828',
        'VA'=>'38.0033855,-79.4587861',
        'WA'=>'38.8993487,-77.0145665',
        'WV'=>'38.9201705,-80.1816905',
        'WI'=>'44.7862968,-89.8267049',
        'WY'=>'43.000325,-107.5545669',
    );

Credit: Github


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #4 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #5 How to uninstall Cocoapods from the Mac OS? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
How to send and receive query strings via links in Angular 9?AngularHow to Install PHP Laravel on MacOS Catalina?PHPQuick Introduction to 11 Array Iteration Methods in JavaScriptJavaScriptThe basics of CSS Box modelCSSSolution for Xcode 11 Command PhaseScriptExecution failed with a nonzero exit code errorMiscellaneousWhat’s new in WordPress 5.5?WordPress