我有以下内容可以在表单上生成状态下拉列表:
$states = array( State , Alabama , Alaska , Arizona , Arkansas );
echo "<select name= choose_state >
";
foreach ($states as $key => $state)
{echo "<option value= $key >$state</option>
";}
echo "</select>";
How would I go about making sure a user
1) only selects one of the options in the array
2) doesn t select the default value? ([0]=> string(5) "State")
edit: validate in php, this is for a form collecting user information before posting to a db
I tried using in_array and got stuck trying to exclude the default value