-1
我有以下一段代碼,它返回許多類別,以及每個類別中的項目計數器。問題是它沒有按字母順序返回。我如何強制他們按字母順序輸出?我認爲它必須與「asort」或什麼,但我似乎無法弄清楚如何。我非常感謝任何建議! :)如何按字母順序排序PHP類別數組?
數組字母順序排序是:
$category_lang[$cat_details['category_id']]
的完整代碼:
while ($cat_details = $db->fetch_array($sql_select_categories))
{
$subcat_link = basename($_SERVER['PHP_SELF']) . '?parent_id=' .$cat_details['category_id'] . $additional_vars;
$categoryCounter = (COUNT_CATS == 1 && !empty($src_details['keywords_search'])) ? $cat_counter[$cat_details['category_id']] : $cat_details['items_counter'];
if ($categoryCounter > 0 || COUNT_CATS == 0) {
$output .= '<tr> ' .
' <td class="contentfont"><a href="' . $subcat_link . '">' . $category_lang[$cat_details['category_id']] . '</a> ' .
(($categoryCounter) ? '<span class="cnt">(' . $categoryCounter . ')</span>' : '') .
' </td> ' .
'</tr> ';
}
}