array_multisort 排序

$bonusdata = $bonusDb->gets($where)->items;
foreach ($bonusdata as $key => $val) {
$tmpArr[$key] = $val['bonus'];
}
array_multisort($tmpArr, SORT_DESC, $bonusdata);
foreach ($bonusdata as $key => $val) {
$bonusDb->setPkid($val['id']);
$bonusDb->set('ranking', $key + 1);
if ($bonusDb->save() === false) {
return false;
}
}
posted @ 2016-06-20 16:09  山南山  阅读(80)  评论(0)    收藏  举报