1
$users = array(
   array('time' => 1398869665, 'name' => 'Jenny', 'age' => 20 ),
   array('time' => 1398854528, 'name' => 'Ben', 'age' => 22),
   array('time' => 1398854536, 'name' => 'Anna', 'age' => 18 ),
   array('time' => 1398869401, 'name' => 'Bob', 'age' => 25 ),
);

$time = array();

foreach($users $key => $user)
{
    $time[$key] = $user['time'];
}

array_multisort($time, SORT_DESC,  $users);

关联(string)键名保持不变,但数字键名会被重新索引。

排序顺序标志:
1.SORT_ASC - 按照上升顺序排序
2.SORT_DESC - 按照下降顺序排序


fengxiuping
330 声望15 粉丝

努力后,相信一切都有可能!