12-21 1,948 views
<?php
$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
1,948 views => 500
)
[1] => Array
(
[title] => 标题4
1,948 views => 400
)
[2] => Array
(
[title] => 标题3
1,948 views => 300
)
[3] => Array
(
[title] => 标题2
1,948 views => 200
)
[4] => Array
(
[title] => 标题1
1,948 views => 100
)
)