当前位置:Gxlcms > PHP教程 > 实现排名版带有趋势的

实现排名版带有趋势的

时间:2021-07-01 10:21:17 帮助过:4人阅读

实现排行版带有趋势的
实现排行版带有趋势的,该怎么实现呢?

分享到:


------解决方案--------------------
//先变形为这样,即用 uid 做键。生成这些数据时就应该这样做好
$old_rank = array(
132=>array('uid'=>132,'use_score'=>61570),
121=>array('uid'=>121,'use_score'=>50932),
145=>array('uid'=>145,'use_score'=>46789),
100=>array('uid'=>100,'use_score'=>39089),
167=>array('uid'=>167,'use_score'=>29089)
);
$new_rank = array(
132=>array('uid'=>132,'use_score'=>61570),
145=>array('uid'=>145,'use_score'=>51932),
121=>array('uid'=>121,'use_score'=>50932),
167=>array('uid'=>167,'use_score'=>40089),
100=>array('uid'=>100,'use_score'=>39089)
);
foreach($new_rank as $k=>$v)
$res[$k] = $v['use_score'] - $old_rank[$k]['use_score'];
print_r($res);
Array
(
[132] => 0
[145] => 5143
[121] => 0
[167] => 11000
[100] => 0
)

人气教程排行