Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中更改数组顺序?_Php_Arrays - Fatal编程技术网

在php中更改数组顺序?

在php中更改数组顺序?,php,arrays,Php,Arrays,我想知道如何更改以下阵列的顺序: Array ( [1] => Array ( [0] => stdClass Object ( [id] => 120 [hteam] => Heatherton [ateam] => Dingley

我想知道如何更改以下阵列的顺序:

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。。这有意义吗?任何帮助都将不胜感激,谢谢:)

您可以使用 php函数,允许定义您自己的排序函数。

您可以使用
php函数,该函数允许定义您自己的排序函数。

您可以使用array_keys()函数提取所有键,然后将旧键映射到新键,最后使用新键构造一个新数组,并使用新键旧键映射从旧数组获取值。

您可以使用array_keys()函数提取所有键,然后将旧键映射到新键,最后使用新键构造一个新数组,使用新键旧键映射从旧数组中获取的值。

我需要按第一个数组键重新排序,当前从1开始。我需要按第一个数组键重新排序,现在从1开始。