Make choose_from_menu behave correctly in the obscure case where an array

contains a zero key and the "selected" variable is a string. Argh.
This commit is contained in:
defacer 2005-04-08 19:32:31 +00:00
parent 63f6f13776
commit 97e28cc66d

View File

@ -652,7 +652,9 @@ function choose_from_menu ($options, $name, $selected='', $nothing='choose', $sc
if (!empty($options)) {
foreach ($options as $value => $label) {
$output .= ' <option value="'. $value .'"';
if ($value == $selected) {
// The gettype() calls are there because otherwise a numeric zero key is a match for any string value
// As gettype() is possibly expensive, only run the check if the simple equality holds true
if ($value == $selected && gettype($value) == gettype($selected)) {
$output .= ' selected="selected"';
}
if ($label === '') {