以下是我抓住我的国家/地区数据的方法
<?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);
}
?>
以下是我填充下拉菜单的方法
<!-- 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
答案 0 :(得分:1)
根据您的代码,只需注释$continents, SORT_ASC,
- 它应该有用。
<?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);
}
?>