Home  >  Article  >  Backend Development  >  有什么步骤可以把一堆数据打乱排效率较好

有什么步骤可以把一堆数据打乱排效率较好

WBOY
WBOYOriginal
2016-06-13 12:07:191039browse

有什么方法可以把一堆数据打乱排效率较好?
网站的首页

我想取出最新50条,然后打乱排序,因为PHP取出50条
在前台只显示15条
SMARTY设了每15分钟更新一次

这样某程度上就像15分钟就更新数据一次了

SQL方面我已单纯只是  order by `time` desc

想在PHP/SMARTY下手脚

section 找了很久很久都没有乱排序的方案

那只能用PHP数组的处理?

我该如何打乱?

SQL数据是用$stmt->fetchAll(PDO::FETCH_ASSOC);  找出来的

所以是二位数组

------解决思路----------------------
先select出来,然后shuffle
------解决思路----------------------
{$row_v[list].title}
你不是按固定顺序输出第二维的吗?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn