w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to get a values from array and display as select list option

Try this one

$districts =get_district(); /* get all data */
$options="";
/* loop through all the choices array  */
foreach($districts[0]['choices'] as $key => $val){
$options.="<option value='".$key."'>".$val."</option>";
    /* append the options of select in $options  */
}

In html

<select name="districts">
<?php echo $options; ?>
</select>




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.