在PHP中排序2D数组

时间:2013-04-22 10:27:58

标签: php arrays sorting

我有以下2D数组:

Array (
[ID] => Array
    (
        [0] => 150
        [1] => 250
    )

[Group] => Array
    (
        [0] => 120
        [1] => 120
    )

[Name] => Array
    (
        [0] => Name 1
        [1] => Name 2
    )

[Price] => Array
    (
        [0] => 9.99
        [1] => 11.99
    )

[Date] => Array
    (
        [0] => 12.04.2013
        [1] => 11.04.2013
    )

[SortIndex] => Array
    (
        [0] => 20
        [1] => 10
    )

我希望在SortIndex-Array升序后对它们进行排序。但是阵列中的不同值与其他值相关。所以关联不能改变。 我怎么能对它们进行排序?

1 个答案:

答案 0 :(得分:1)

有没有理由不将数组转换为更合适的形式?

Array (
[0] => Array
    (
        [ID] => 150
        [Group] => 120
    )

[1] => Array
    (
        [ID] => 250
        [GROUP] => 120
    )
....