$data= array(
0 => array(
'uid' => 100,
'name' => 'Sandra Shush',
'pic_square' => 'urlof100'
),
1 => array(
'uid' => 5465,
'name' => 'Stefanie',
'pic_square' => 'urlof5465'
),
2 => Array(
'uid' => 40489,
'name' => 'Karen',
'pic_square' => 'urlof40489'
),
3 => Array(
'uid' => 506978,
'name' => 'Casual',
'pic_square' => 'urlof506978'
)
);
$sort = array_column($data, 'uid'); //从记录中取出uid列
array_multisort($sort, SORT_DESC, $data); //倒序排列
var_dump($data);
排序后的 $data 变成了按照 uid 倒序排列
进行数据切片
$result = array_slice($data,0,2); //数组取切片,可做数据翻页处理
var_dump($result);