Fair enough,
I am the sole PHP programmer @ work. So I do wite an extensive list of functions I find myself using often.
Also, that function can be copied verbatim, and used quite easily.. one could add complexity by saying:
<?php
$options = $_REQUEST['options'];
function opt_selected($option_var, $post_var) {
if ($option_var == $post_var) {
echo "<option selected>$option_var</option>";
} else {
echo "<option>$option_var</option>";
}
}
echo "<select name="blah">";
opt_selected("Option 1",$options);
opt_selected("Option 2",$options);
opt_selected("Option 3",$options);
echo "</select>";
That's not needed and overcomplex, but would work again.. Verbatim.
On the note of naming it "selected", great minds think alike.
big.nerd