简体   繁体   English

PHP的:按字母顺序排序多维数组?

[英]php: alphabetically sort multi-dimensional array by its key?

I need to sort some nested arrays alphabetically by their key... 我需要按其键的字母顺序对一些嵌套数组进行排序...

Is there a native PHP function to sort the following so the nested arrays were in order like 是否有本机PHP函数可以对以下内容进行排序,以便嵌套数组像

[G] -> array... [G]->数组...

[I] -> array... [I]->数组...

[P] -> array... [P]->数组...

[S] -> array... [S]->数组...

[T] -> array... [T]->数组...

here is an example unsorted array: 这是一个未排序数组的示例:

[S] => Array
    (
        [26] => Array
            (
                [name] => St Georges Hall
                [tel] => sdfa
            )

        [27] => Array
            (
                [name] => St Werburghs Community Centre
                [tel] => sadf
            )
    )

[G] => Array
    (
        [40] => Array
            (
                [name] => The Golden Guinea
                [tel] => 
            )

        [41] => Array
            (
                [name] => The Golden Lion
                [tel] => One of Bristol's key live music pubs
            )

    )

[I] => Array
    (
        [45] => Array
            (
                [name] => The Island
                [tel] => asdfgf
            )

    )

[P] => Array
    (
        [50] => Array
            (
                [name] => The Prom
                [tel] => Reliable gig venue and blues hotspot on Gloucester road
            )

    )

[T] => Array
    (
        [51] => Array
            (
                [name] => The Thunderbolt
                [tel] => Small gig venue in Totterdown
            )

        [52] => Array
            (
                [name] => Tobacco Factory
                [tel] => A modern cafe-bar with regular live music.
            )

    )

是的, ksort

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM