html code for combo box with php array code example

Example 1: php static dropdown list example

<?php
$toy_cars = array("Pull Back Cars","Remote Cars", "Electric Cars", "Toy Race Cars","Lightening Cars");
$array_length = count($toy_cars);
?>
<select name="dynamic_data">
<?php
for ($i=0;$i<$array_length;$i++){
?>
<option value="<?=$toy_cars[$i];?>"><?=$toy_cars[$i];?></option>
<?php
}
?>
</select>

Example 2: php html select option array

foreach($countries as $cc => $name) {
    echo '<option value="' . $cc . '">' . $name . '</option>';
}
//exemple2 
$countries = get_list_countries();
foreach($countries as $c) {  
         echo '<option value="' . $c['id'] . '">' . $c['country_name'] . '</option>';
        }

Tags:

Html Example