Today I decided to share with you a series of US State selection boxes built using PHP.

First the Arrays that contain the state abbreviation and full name.

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

Next we have the most common ways to display this selection.

1. Display full state name with value of abbreviation.

<?php
echo '<select id="state" name="state">';
for($i=0;$i<=count($state_array)-1;$i++){
	echo '<option value="'.$state_array[$i].'">'.$state_name[$i].'</option>';
}
echo '</select>';
?>

2. Display state name with value of state name.

<?php
echo '<select id="state" name="state">';
for($i=0;$i<=count($state_array)-1;$i++){
	echo '<option value="'.$state_array[$i].'">'.$state_array[$i].'</option>';
}
echo '</select>';
?>