array_to_html_select

Custom PHP Function


function array_to_html_select($a, $b, $c = false, $d = false) { $e = "<select "; if ($d === true) { $e .= "disabled=\"disabled\" "; } $e .= "id=\"$a\" name=\"$a\">"; foreach ($b as $f => $g) { $e .= "<option "; if (($c !== false) && ((is_numeric($c) && ($f == $c)) || (is_string($c) && (strcmp($f, $c) == 0)))) { $e .= "selected=\"selected\" "; } $e .= "value=\"$f\">" . htmlentities($g) . "</option>"; } $e .= "</select>"; return ($e); }