How to set selected=”selected” for the saved option array below. Thanks !
e.g
<option value="Facebook">Facebook</option>
<option value="Twitter" selected="selected">Twitter</option>
<select name="'. $id .'['.$order.'][url]" id="'. $id .'['.$order.'][url]">
$socialicons = array ('facebook' => 'Facebook', 'twitter' => 'Twitter');
foreach ($socialicons as $socialicon) {
<option value="'.$socialicon.'" />'.$socialicon.'</option>
}
</select>
You will have the sent value in your POST array at
$_POST[$id][$order]['url']I think. Then it’s just a matter of comparing the sent value with the current value in the loop:I am not totally sure about the
$_POSTarray, so you might have to tweak around with that or search for how multidimensional$_POSTis accessed.If you save the selection somewhere else, e.g. in a database, you can compare it with the value from there.