嗨,我有来自模板的以下代码。
<ul class="sub-categories">
<?php
foreach ($category->getChildren() as $child) {
if (!$child->totalItemCount()) continue;
$link = $this->app->route->category($child);
$item_count = ($this->params->get('template.show_sub_categories_item_count')) ? ' <span>('.$child->totalItemCount().')</span>' : '';
echo '<li><a href="'.$link.'" title="'.$child->name.'">'.$child->name.'</a>'.$item_count.'</li>';
}
?>
</ul>
我想对子类别项目(在代码中进一步按州细分的城市)进行排序。
我以为我可以对以下数组进行排序 $category->getChildren() 但它不起作用。所以我对它做了一个回声,它说数组,所以我在那个数组上做了 var_dump 并得到了一个 bool(true) 。当我尝试其他输出方式(print_r)时,它使页面崩溃。
我不太了解数组,所以有人可以解释这个不是数组的数组是什么吗?我如何对城市列表进行排序?
谢谢!