我这里用的是thinkcmf5 column,toArray,这些是框架自带的函数
```
<?php
//多条
//取出red_prize的ID并转成一维数组
$list = Db::name('red_prize')->column('id');
// $list = Db::name('red_prize')->select();
//$list = array_column($list,'id');
$rand_list = array_rand($list,3);//随机抽取3条
$tuijian_array = array();
foreach ((array)$rand_list as $key) {
$tuijian_array[] = $list[$key];
}
$randArr = Db::name('red_prize')->where('id','in',$rand_list)->select()->toArray();
```
网友评论