<select id="property_zoning" multiple="multiple" name="zoning[]">
<?php echo showOptionsDrop($zoning_arr, '',$_SESSION["foo"]["zoning"]);?>
</select>
function showOptionsDrop($array, $multi=NULL, $selected=NULL){
if($multi == NULL){
$string = '<option value="">Select one</option>'."\n";
} else {
$string = '<option value="">None</option>'."\n";}
foreach($array as $k => $v){
$s=NULL;
if($k == $selected || $v == $selected)
{
$s = ' selected="selected"';
}
$string .= '<option value="'.$k.'"'.$s.'>'.$v.'</option>'."\n";
}
return $string;
}
So this function works terrific for a regular select input, however, with the multi select, it does not function with $selected as an array. I would like to implement something so that if $selected is an array, it iterates through. But when I attempted it, it just marked them all as selected.
And as always, I greatly appreciate the help. I'm sure it involves some type of recursion?