It is THIS line of code:
[B]echo "</select>";[/B]
return $dropdown;
You echo out the close of the select tag, and you RETURN all else.
So, when the function is called, you echo the end tag BEFORE outputting all else..
The fix is to concatenate the value to the dropdown var:
$dropdown .= "</select>";
return $dropdown;
<?php
function create_dropdown($identifier,$pairs,$firstentry,$multiple="",$key="")
{
$dropdown = '<select name="'.$identifier.'" '.$multiple.'>
<option name="">'.$firstentry.'</option>'."\n";
foreach($pairs as $value => $name)
{
if($value == $key)
{
$dropdown .= '<option name="'.$value.'" selected="selected">'.$name.'</option>'."\n";
}
else
{
$dropdown .= '<option name="'.$value.'">'.$name.'</option>'."\n";
}
}
$dropdown .= '</select>'."\n";
return $dropdown;
}
?>