php:按字母顺序按键排序多维数组?

时间:2010-09-05 12:08:46

标签: php arrays sorting

我需要按字母顺序对一些嵌套数组进行排序......

是否有本机PHP函数对以下内容进行排序,因此嵌套数组的顺序与

相同

[G] - >阵列...

[I] - >阵列...

[P] - >阵列...

[S] - >阵列...

[T] - >阵列...

这是一个未排序的数组示例:

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

    )

1 个答案:

答案 0 :(得分:9)

是的,ksort