PHP array problem?
- by needHeLp
I'm new to PHP and I want this code <option value="" disabled="disabled">-------------</option> to be disabled when the php code is building my select list of options. How can I fix my php code so it will always set that specific option to disabled?
Here is part of the php code.
echo '<select name="country" id="country" size="20">' . "\n";
foreach($countries as $option) {
if ($option == $state) {
echo '<option value="' . $option . '" selected="selected">' . $option . '</option>' . "\n";
} else {
echo '<option value="'. $option . '">' . $option . '</option>'."\n";
}
}
echo '</select>';
Here is part of the HTML code that is outputed from the php code.
<option value="United States">United States</option>
<option value="Australia">Australia</option>
<option value="Canada">Canada</option>
<option value="United Kingdom">United Kingdom</option>
<option value="India">India</option>
<option value="" disabled="disabled">-------------</option>
<option value="Afghanistan">Afghanistan</option>
<option value="Aland Islands">Aland Islands</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>