How to generate a prize based on the prize's winning probability value (0-10000) in php?
How to implement the algorithm? Among 10 prizes
認(rèn)證高級(jí)PHP講師
Every station understands what you mean, but the easier way to draw immediately is:
1.從0到100隨即生成一個(gè)整數(shù)
2.設(shè)置中獎(jiǎng)范圍 比如10%的中獎(jiǎng)率 那么1到10是中獎(jiǎng)數(shù)字
3.然后根據(jù)抽中后的數(shù)字判斷是幾等獎(jiǎng)
If you feel it is not safe, you can also increase the range, such as 0 to 10,000, and then set the winning range, etc.