PHP: Sélectionner un élément du menu ‘select, option’ automatiquement

Author:


Download

<?php
$fruits = array('Orange' => 'O',
                 'Banane' => 'B',
                 'Pomme' => 'P',
                 'Fraise' => 'F');
 
print '
<select name="sweet">';
 
foreach ($fruits as $option => $label) {
    print '
<option value="' .$option .'"';
    // Sélectionner l''option pomme
    if ($option == 'Pomme') {
        print ' selected="selected"';
    }
    print "> $label</option>
 
";
}
print '</select>
 
';
?>

Leave a Reply

Your email address will not be published. Required fields are marked *


6 + = ten