[eluser]mddd[/eluser]
The line saying
Code:
if ($selected==$key){
will be true for $selected = 0 because 0 == ''.
You can check for type by using
. This only gives 'true' when the variables are of the same type!
Another solution could be to check if $selected contains a number:
Code:
if (is_numeric($selected) && $selected==$key)
.
By the way, why are you making an array first, and then only looping through that array? The function could be written shorter:
Code:
function minutes($name,$extra='',$selected='')
{
$html = '<select name="'.$name.'" id="'.$name.'"'.$extra.'><option value="">- Minutes -</option>';
for ($i=0; $i<60; $i++)
{
$html.= '<option value="'.$i.'"';
if ($selected === $i) $html .= ' selected';
$html.= '>'.$i.'</option>';
}
$html.= '</select>';
return $html;
}