0

次の配列の順序をどのように変更できるか疑問に思っていました:

Array
(
    [1] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 120
                    [hteam] => Heatherton
                    [ateam] => Dingley
                    [round] => 1
                    [catid] => Seniors
                    [date] => Saturday 14th April, 2012
                    [time] => 12:00am
                    [venue] => Heatherton Recreational Reserve
                )

            [1] => stdClass Object
                (
                    [id] => 121
                    [hteam] => Heatherton
                    [ateam] => Dingley
                    [round] => 1
                    [catid] => Reserves
                    [date] => Saturday 14th April, 2012
                    [time] => 11:45am
                    [venue] => Heatherton Recreational Reserve
                )

        )

    [2] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 122
                    [hteam] => Clayton
                    [ateam] => Heatherton
                    [round] => 2
                    [catid] => Seniors
                    [date] => Saturday 21st April, 2012
                    [time] => 12:00am
                    [venue] => Clayton Reserve
                )

            [1] => stdClass Object
                (
                    [id] => 139
                    [hteam] => Clayton
                    [ateam] => Heatherton
                    [round] => 2
                    [catid] => Reserves
                    [date] => Saturday 21st April, 2012
                    [time] => 12:00am
                    [venue] => Clayton Reserve
                )
        )

    [3] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 123
                    [hteam] => Heatherton
                    [ateam] => St Pauls
                    [round] => 3
                    [catid] => Seniors
                    [date] => Saturday 28th April, 2012
                    [time] => 12:00am
                    [venue] => Heatherton Recreational Reserve
                )

            [1] => stdClass Object
                (
                    [id] => 140
                    [hteam] => Heatherton
                    [ateam] => St Pauls
                    [round] => 3
                    [catid] => Reserves
                    [date] => Saturday 28th April, 2012
                    [time] => 12:00am
                    [venue] => Heatherton Recreational Reserve
                )

        )

    [4] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 124
                    [hteam] => Mordialloc
                    [ateam] => Heatherton
                    [round] => 4
                    [catid] => Seniors
                    [date] => Saturday 5th May, 2012
                    [time] => 02:00pm
                    [venue] => Ben Kavanagh Reserve
                )

            [1] => stdClass Object
                (
                    [id] => 141
                    [hteam] => Mordialloc
                    [ateam] => Heatherton
                    [round] => 4
                    [catid] => Reserves
                    [date] => Saturday 5th May, 2012
                    [time] => 11:45am
                    [venue] => Ben Kavanagh Reserve
                )

        )
)

^^からこれまで:

Array
(

    [3] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 123
                    [hteam] => Heatherton
                    [ateam] => St Pauls
                    [round] => 3
                    [catid] => Seniors
                    [date] => Saturday 28th April, 2012
                    [time] => 12:00am
                    [venue] => Heatherton Recreational Reserve
                )

            [1] => stdClass Object
                (
                    [id] => 140
                    [hteam] => Heatherton
                    [ateam] => St Pauls
                    [round] => 3
                    [catid] => Reserves
                    [date] => Saturday 28th April, 2012
                    [time] => 12:00am
                    [venue] => Heatherton Recreational Reserve
                )

        )

    [4] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 124
                    [hteam] => Mordialloc
                    [ateam] => Heatherton
                    [round] => 4
                    [catid] => Seniors
                    [date] => Saturday 5th May, 2012
                    [time] => 02:00pm
                    [venue] => Ben Kavanagh Reserve
                )

            [1] => stdClass Object
                (
                    [id] => 141
                    [hteam] => Mordialloc
                    [ateam] => Heatherton
                    [round] => 4
                    [catid] => Reserves
                    [date] => Saturday 5th May, 2012
                    [time] => 11:45am
                    [venue] => Ben Kavanagh Reserve
                )

        )

        [1] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 120
                    [hteam] => Heatherton
                    [ateam] => Dingley
                    [round] => 1
                    [catid] => Seniors
                    [date] => Saturday 14th April, 2012
                    [time] => 12:00am
                    [venue] => Heatherton Recreational Reserve
                )

            [1] => stdClass Object
                (
                    [id] => 121
                    [hteam] => Heatherton
                    [ateam] => Dingley
                    [round] => 1
                    [catid] => Reserves
                    [date] => Saturday 14th April, 2012
                    [time] => 11:45am
                    [venue] => Heatherton Recreational Reserve
                )

        )

    [2] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 122
                    [hteam] => Clayton
                    [ateam] => Heatherton
                    [round] => 2
                    [catid] => Seniors
                    [date] => Saturday 21st April, 2012
                    [time] => 12:00am
                    [venue] => Clayton Reserve
                )

            [1] => stdClass Object
                (
                    [id] => 139
                    [hteam] => Clayton
                    [ateam] => Heatherton
                    [round] => 2
                    [catid] => Reserves
                    [date] => Saturday 21st April, 2012
                    [time] => 12:00am
                    [venue] => Clayton Reserve
                )
        )
)

したがって、この例では、配列は 3 番から始まり、4 番に進み、再び 1 番に戻ります..それが理にかなっていますか? どんな助けでも大歓迎です、ありがとう:)

4

2 に答える 2

2

独自のソート関数を定義できるusort php 関数を使用できます。

于 2012-05-08T06:22:00.980 に答える
1

array_keys() 関数を使用してすべてのキーを抽出し、古いキーから新しいキーへのマップを作成し、最後に新しいキーを使用して新しい配列を構築し、新しい key-old を使用して古い配列から値を取得できます。キーマップ。

于 2012-05-08T06:41:20.440 に答える