title: PHP Script for States to Abbreviations Not Working Correctly
body: <p>I'm not sure what's wrong with this script.  When I run it it only gives me the first letter of the abbreviation.</p>
  
  <p>I didn't write the abbreviation part, I found that online.  The only parts of the script that are mine are the GET and Includes.</p>
  
  <p>I've set the state variable to a state and I still get the same thing so I know it's not my portion of the code.  If anyone knows what the issue is please let me know.</p>
  
  <p>Here is the updated code as suggested.  Still having the same problem.</p>
  
  <pre><code>$state = 'Alabama';
  
  function convert_state($name, $get = 'abbr') {
  $states = array(
  'Alabama'=&gt;'AL',
  'Alaska'=&gt;'AK',
  'Arizona'=&gt;'AZ',
  'Arkansas'=&gt;'AR',
  'California'=&gt;'CA',
  'Colorado'=&gt;'CO',
  'Connecticut'=&gt;'CT',
  'Delaware'=&gt;'DE',
  'Florida'=&gt;'FL',
  'Georgia'=&gt;'GA',
  'Hawaii'=&gt;'HI',
  'Idaho'=&gt;'ID',
  'Illinois'=&gt;'IL',
  'Indiana'=&gt;'IN',
  'Iowa'=&gt;'IA',
  'Kansas'=&gt;'KS',
  'Kentucky'=&gt;'KY',
  'Louisiana'=&gt;'LA',
  'Maine'=&gt;'ME',
  'Maryland'=&gt;'MD',
  'Massachusetts'=&gt;'MA',
  'Michigan'=&gt;'MI',
  'Minnesota'=&gt;'MN',
  'Mississippi'=&gt;'MS',
  'Missouri'=&gt;'MO',
  'Montana'=&gt;'MT',
  'Nebraska'=&gt;'NE',
  'Nevada'=&gt;'NV',
  'New Hampshire'=&gt;'NH',
  'New Jersey'=&gt;'NJ',
  'New Mexico'=&gt;'NM',
  'New York'=&gt;'NY',
  'North Carolina'=&gt;'NC',
  'North Dakota'=&gt;'ND',
  'Ohio'=&gt;'OH',
  'Oklahoma'=&gt;'OK',
  'Oregon'=&gt;'OR',
  'Pennsylvania'=&gt;'PA',
  'Rhode Island'=&gt;'RI',
  'South Carolina'=&gt;'SC',
  'South Dakota'=&gt;'SD',
  'Tennessee'=&gt;'TN',
  'Texas'=&gt;'TX',
  'Utah'=&gt;'UT',
  'Vermont'=&gt;'VT',
  'Virginia'=&gt;'VA',
  'Washington'=&gt;'WA',
  'West Virginia'=&gt;'WV',
  'Wisconsin'=&gt;'WI',
  'Wyoming'=&gt;'WY'
  );
  if($get == 'name') {
  // in this case $name is actually the abbreviation of the state name and you want the full name
  $states = array_flip($states);
  }
  
  return $states[$name];
  }
  </code></pre>