我有一系列新闻
Array
(
[0] => Array
(
[news_published] => 1337192831
[news_category] => 5
)
[1] => Array
(
[news_published] => 1334566743
[news_category] => 5
)
[2] => Array
(
[news_published] => 1340092425
[news_category] => 6
)
[3] => Array
(
[news_published] => 1339740173
[news_category] => 6
)
[4] => Array
(
[news_published] => 1336148837
[news_category] => 6
)
)
Run Code Online (Sandbox Code Playgroud)
我如何按降序对news_published进行排序....我试过'usort'但是无法找到正确的结果有人可以建议我吗?
试试这个 :
$arr = your array;
$sort = array();
foreach($arr as $k=>$v) {
$sort['news_published'][$k] = $v['news_published'];
}
array_multisort($sort['news_published'], SORT_DESC, $arr);
echo "<pre>";
print_r($arr);
Run Code Online (Sandbox Code Playgroud)