I have an issue with this form. I need to keep the values selected and I don't find the way. The thread where I posted the first time: Create php fom select multiple taking values from a table bd
The form:
<select name="fan[]" multiple="multiple"> <!-- Aquí se llama a la función verificarListaMultiple -->
    <?php
        foreach ($deportes as $aficion) {
            echo "<option value='".$aficion['idD']."'";
            if (isset($fan)) {
                verificarListaMultiple($aficion,$fan);
            }
            echo " >{$aficion['nombreDep']}</option>\n";
        }
    ?>            
</select>
And the function I'm trying to use:
function verificarListaMultiple($array, $valor) {
    if (in_array($valor, $array)) {
        echo 'selected = "selected"';
    }
}
Thanks.
 
    