Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to populate dropdown list with array values in php

<select name="mydropdown">
        <option selected="selected">Choose one</option>
        <?php
        // A sample product array
        $products = array("Mobile", "Laptop", "Tablet", "Camera");
        
        // Iterating through the product array
        foreach($products as $item){
            echo "<option value='strtolower($item)'>$item</option>";
        }
        ?>
</select>
 
PREVIOUS NEXT
Tagged: #populate #dropdown #list #array #values #php
ADD COMMENT
Topic
Name
1+1 =