"auto populate a select box using an array in php" Answer’s

0

supposing the array looks like:

$array = array(
  1=>"My first option",
  2=> "My second option"
);

<select>
  <?php foreach($array as $key => $value) { ?>
    <option value="<?php echo $key ?>"><?php echo $value ?></option>
  <?php }?>
</select>
Wednesday, March 31, 2021
 
skrilled
answered 10 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share