开发者

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

I need to sort some nested arrays alphabetically 开发者_StackOverflowby their key...

Is there a native PHP function to sort the following so the nested arrays were in order like

[G] -> array...

[I] -> array...

[P] -> array...

[S] -> array...

[T] -> array...

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.
            )

    )


Yes, ksort.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜