作者 王智

1111

... ... @@ -157,9 +157,7 @@ class Config extends Api
$Ids[] = $v['id'];
}
// $Id = array_rand($Ids, 1);
$NEW = shuffle($Ids);
dump($NEW);
die;
$NEW = $this->shuffle_assoc($Ids);
$List = Db::name('gift_message')->where('id', $NEW[0])->find();
$data = [
'Content' => $List['content']
... ... @@ -168,6 +166,14 @@ class Config extends Api
$this->success('成功', $data);
}
function shuffle_assoc($array)
{
$randomized_keys = array_rand($array, count($array));
foreach ($randomized_keys as $current_key) {
$output[$current_key] = $array[$current_key];
}
return $output;
}
/**
* Config接口
... ...