我有一个类似程序的抽奖活动: 用户将x个令牌放置在一个项目上。这被记录到数据库中 USER_ID,ITEM_ID,number_of_tokens在抽奖代码中用PHP生成真随机数
到时候画的,我做了以下内容:
$ballots = array();
$users = all users that placed at least one token on Item A.
foreach($users as $user)
{
$number_of_ballots = Get number of ballots this User placed on Item A
for($i = 1; $i leq $number_of_ballots; $i++)
{
$ballots[] = $user->id;
}
}
shuffle($ballots);
$winner_user_id = mt_rand(0, count($ballots) -1);
现在我的问题是:
- 这是否保证随机选择?
- 在物品A上放置10个标记的人是否比在物品A上放置1个标记的人获得10倍的获胜机会?
感谢您的帮助。
真棒。非常感谢你。 – luv2Code
Random.org是。看起来非常“真实”且可靠。 – luv2Code