Create a state dropdown with an abbreviation option and a full option
I'm going to assume here (having done this myself before when I first started out with PHP), that you are storing the state data in a MySQL database, which you are pulling and storing in the global $state var. 

Do not do that. You're slowing down the entire program by making a call out to the database for what is pretty much static data (the last state to join the union joined 55 years ago). 

Now, I would just have the dropdowns stored in functions which just return a string. One function for long name, one for abbreviated. 

However, using this as an exercise for you in DRY, I went ahead and created a class, StateDropDown, which contains an associative array of states/properties and their abbreviation. On initiation, the class generates the output form. If the $style contains 'abbr', then we use the abbreviated version after performing a ksort(). Otherwise, since the data in the array is static and already sorted as we prefer, we don't perform an asort and just go straight to storing the select form in a property $output. 

class StateDropDown{
    protected $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",
        "American Samoa" =&gt; "AS",
        "District of Columbia" =&gt; "DC",
        "Federated States of Micronesia" =&gt; "FM",
        "Guam" =&gt; "GU",
        "Marshall Islands" =&gt; "MH",
        "Northern Mariana Islands" =&gt; "MP",
        "Palau" =&gt; "PW",
        "Puerto Rico" =&gt; "PR",
        "Virgin Islands" =&gt; "VI",
        "Armed Forces Africa" =&gt; "AE",
        "Armed Forces Americas" =&gt; "AA",
        "Armed Forces Canada" =&gt; "AE",
        "Armed Forces Europe" =&gt; "AE",
        "Armed Forces Middle East" =&gt; "AE",
        "Armed Forces Pacific" =&gt; "AP"
    );
    public $output = "";

    public function __construct($style = false, $form = null){
        if($style === true){
            ksort($this-&gt;states);
        }

        $this-&gt;output = "&lt;select name='state'&gt;";
        $this-&gt;output .= "&lt;option value=''&gt;--&lt;/option&gt;";

        foreach($this-&gt;states as $name =&gt; $abbr){
            $this-&gt;output .= "&lt;option value='" . $abbr . "'";
            if($form === $abbr){
                $this-&gt;output .= "selected='selected'";
            }

            if($style === true){
                $this-&gt;output .= "&gt;" . $abbr . "&lt;/option&gt;";
            } else {
                $this-&gt;output .= "&gt;" . $name . "&lt;/option&gt;";
            }
        }
        $this-&gt;output .= "&lt;/select&gt;";
    }
}


To use, simply instantiate and echo output.

Here, we do a regular state name, with no selected state: 

$dropdown = new StateDropDown();
echo $dropdown-&gt;output;


Here, we do a regular state name, with a selected state, NY: 

$dropdown = new StateDropDown(null, "NY");
echo $dropdown-&gt;output;


Here, we do an abbreviated state name, with no selected state: 

$dropdown = new StateDropDown(true);
echo $dropdown-&gt;output;


Here, we do an abbreviated state name, with a selected state, FL: 

$dropdown = new StateDropDown(true, 'FL');
echo $dropdown-&gt;output;


While we may have the overhead of instantiating a new object, etc - we save on a possible database call. Additionally, we no longer do multiple checks, but rather do one check for abbreviation preference and assume the non-abbreviated by default, as well as keeping it non-abbreviated sort by default.

EDIT

Since OP indicated that I was incorrect in my assumption that they were storing this data in a database, I've modified my above Class into a function which does the same thing:

function statesDropdown($style = false, $form = null){
    $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",
        "American Samoa" =&gt; "AS",
        "District of Columbia" =&gt; "DC",
        "Federated States of Micronesia" =&gt; "FM",
        "Guam" =&gt; "GU",
        "Marshall Islands" =&gt; "MH",
        "Northern Mariana Islands" =&gt; "MP",
        "Palau" =&gt; "PW",
        "Puerto Rico" =&gt; "PR",
        "Virgin Islands" =&gt; "VI",
        "Armed Forces Africa" =&gt; "AE",
        "Armed Forces Americas" =&gt; "AA",
        "Armed Forces Canada" =&gt; "AE",
        "Armed Forces Europe" =&gt; "AE",
        "Armed Forces Middle East" =&gt; "AE",
        "Armed Forces Pacific" =&gt; "AP"
    );
    $output = "";
    if($style === true){
        ksort($states);
    }

    $output = "&lt;select name='state'&gt;";
    $output .= "&lt;option value=''&gt;--&lt;/option&gt;";

    foreach($states as $name =&gt; $abbr){
        $output .= "&lt;option value='" . $abbr . "'";
        if($form === $abbr){
            $output .= "selected='selected'";
        }

        if($style === true){
            $output .= "&gt;" . $abbr . "&lt;/option&gt;";
        } else {
            $output .= "&gt;" . $name . "&lt;/option&gt;";
        }
    }
    $output .= "&lt;/select&gt;";

    return $output;
}


To output the dropdown, simply do:

echo statesDropdown();