0
我有以下php array
对象:如何在PHP中使用对象元素对数组进行排序?
"requests": [
{
"id": 111,
"time: 123123123,
"data": "testc"
},
{
"id": 200 ,
"time: 433123123,
"data": "testb"
},
{
"id": 300 ,
"time: 33123123,
"data": "testb"
}
]
我想只有requests->time
对它进行排序。怎么做?我不想按id
排序。所有数据应按照time ASC
排序。
http://stackoverflow.com/questions/16306416/sort-php-multi-dimensional-array-based-on-key – sozkul
使用[usort()](http://www.php.net/manual/en/ function.usort.php) –
如果你从查询中获得这些数据,那么只使用'ORDER BY time ASC'。否则使用'usort()' –