gpt4 book ai didi

php - 搜索php后对数组值进行排序

转载 作者:行者123 更新时间:2023-11-29 13:56:13 25 4
gpt4 key购买 nike

由于某些原因,您好当我使用表单(POST 方法)进行搜索时,我得到了一个如下所示的数组:

      Array(
[0] =>Array ( [0] => 2008 [1] => Name1 [2] => Surname1 )
[1] =>Array ( [0] => 2009 [1] => Name2 [2] => Surname2 )
[2] =>Array ( [0] => 2010 [1] => Name3 [2] => Surname3 )
)

如何在不执行任何其他查询并使用 $_GET 参数或另一个参数来获取如下所示的数组的情况下对该数组进行排序:

       Array(
[0] =>Array ( [0] => 2010 [1] => Name3 [2] => Surname3 )
[1] =>Array ( [0] => 2009 [1] => Name2 [2] => Surname2 )
[2] =>Array ( [0] => 2008 [1] => Name1 [2] => Surname1 )
)

最佳答案

使用array_reverse()函数。

手册:http://php.net/manual/en/function.array-reverse.php

关于php - 搜索php后对数组值进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15824424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com