zblog获取随机文章
简单粗暴,随机使用文章时间或者文章访问量排序,获取1000篇文章,然后打乱。
$count = 10; //随机文章数量 $articles = $zbp->GetArticleList('*',null,array(mt_rand(0,1)?'log_ViewNums':'log_PostTime'=>mt_rand(0,1)?'DESC':'ASC'),1000); shuffle($articles); $posts = count($articles) > $count ? array_chunk($articles,$count)[0] : $articles; foreach ($posts as $post){ echo $post->Title; }
千万不要用网上其它的教程里面用rand()函数的,文章一多,后台就爆
原文:https://kfuu.cn/zblogjiaocheng/27.html