Home >Backend Development >PHP Tutorial >数组自定义排序?该如何处理

数组自定义排序?该如何处理

WBOY
WBOYOriginal
2016-06-13 12:02:54884browse

数组自定义排序?

<br />Array<br />(<br />    [ban] => Array<br />        (<br />            [0] => Array<br />                (<br />                    [id] => 1<br />                    [uid] => 1<br />                    [username] => admin                 <br />                    [posttime] => 2014-07-19 11:54<br />                )<br />        )<br /> <br />    [ale] => Array<br />        (<br />            [0] => Array<br />                (<br />                    [id] => 2<br />                    [uid] => 1<br />                    [username] => admin<br />                    [posttime] => 2014-07-19 12:02<br />                ) <br />        )<br />	[text] => Array<br />        (<br />            [0] => Array<br />                (<br />                    [id] => 5<br />                    [uid] => 1<br />                    [username] => admin<br />                    [posttime] => 2014-07-19 12:02<br />                ) <br />        )<br />)<br />




++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

我想让,,Array[ale] 排第一,Array[text] 排第三, Array[ban] 排第三,这个三个键值是固定。
如果 Array[text] 下面没数据 ,那么这个就不显示,Array[ale] 排第一, Array[ban] 排第二


------解决方案--------------------
这跟排序有什么关系?
------解决方案--------------------
数组的键只有三个固定值吗?是的话直接用自定义排序函数usort,或者也可以依次取值重新保存。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn