$array = [
[
'title' => '标题5',
'views' => 500
],
[
'title' => '标题3',
'views' => 300
],
[
'title' => '标题2',
'views' => 200
],
[
'title' => '标题4',
'views' => 400
],
[
'title' => '标题1',
'views' => 100
],
];
usort($array, function ($item1, $item2) {
return $item1['views'] < $item2['views'];
});
print_r($array);
#result:
Array
(
[0] => Array
(
[title] => 标题5
279 views => 500
)
[1] => Array
(
[title] => 标题4
279 views => 400
)
[2] => Array
(
[title] => 标题3
279 views => 300
)
[3] => Array
(
[title] => 标题2
279 views => 200
)
[4] => Array
(
[title] => 标题1
279 views => 100
)
)