0

虽然这个帖子有很多类似的话题,但在这个论坛和网络上都没有重复,或者也许有但我找不到。

我需要按 KEY 的字母顺序对这个数组进行排序。问题是,所有的 KEY 都是动态的,所以有 STATIC 可以依赖。

除了其他帖子,我还查看了 PHP 的排序函数,如 multisort、ksor 等。

错误列出:在 ACADEMIC 下,[Students] 和 [Staff] 在 MARKETING [Applications] 和 [Activity] 下

提前致谢

大批

Array
(
    [ACADEMIC] => Array
        (
            [Communications] => Array
                (
                    [Email] => academic/email
                    [Sms] => academic/sms
                )

            [Exams] => Array
                (
                    [Assessments] => academic/assessments
                )

            [Students] => Array
                (
                    [Progress] => academic/progress
                )

            [Staff] => academic/staff
        )

    [ACCOUNTS] => Array
        (
            [Order] => accounts/order
        )

    [ADMIN] => Array
        (
            [Menus] => admin/menus
            [Permissions] => admin/permissions
            [Roles] => admin/roles
            [Users] => admin/users
        )

    [AGENTS] => Array
        (
            [New] => agents/new
        )

    [MARKETING] => Array
        (
            [Applications] => Array
                (
                    [Edit] => marketing/edit
                    [New] => marketing/new
                )

            [Activity] => marketing/activity
        )

)
4

1 回答 1

0

找到了方法:

foreach ($array as $key => $inner)
{
   ksort($array[$key]);
}
于 2013-04-09T12:43:14.990 回答