Created
August 1, 2016 14:29
-
-
Save danielrw7/07edcd4850add4f0366188d6dc7d098b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function make_select($name, $options, $selected = "", $additional_attrs = "") { | |
$res = "<select"; | |
if ($name) { | |
$res .= " name='$name'"; | |
} | |
if ($additional_attrs) { | |
$res .= " $additional_attrs"; | |
} | |
$res .= ">"; | |
foreach ($options as $value => $label) { | |
$res .= "<option value='$value'"; | |
if ($selected == $value) { | |
$res .= " selected"; | |
} | |
$res .= ">$label"; | |
$res .= "</option>"; | |
} | |
$res .= "</select>"; | |
return $res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment