Details
- I want to populate a dropdown-menu of my county list in ascending order
- A-Z
What I've tried
Here is how I grab my countries array
<?php
if(is_array($distributors)) {
foreach ($distributors as $k => $v)
{
$continents[$k] = $v['distributor']['continent_id'];
$countries[$k] = $v['hq_country']['name'];
}
array_multisort(
$continents, SORT_ASC,
$countries, SORT_ASC,
$distributors);
}
?>
Here is how I populate my dropdown menu
<!-- Dropdown-Menu : Country Names -->
<div class="col-sm-6 drop-down ">
Select Country :
<select id="state" onchange="window.location=this.value" >
<option value="">--Select--</option>
<?php
foreach(array_unique($countries) as $country){ ?>
<option value="#<?php echo $country ; ?> ">
<?php echo $country ; ?>
</option>
<?php } ?>
</select>
</div>
Here is my result
Want to see my list live ? HERE