Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the Code of php Lucky turntable

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to realize the code of php lucky turntable". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "php lucky turntable code how to achieve" it!

Php lucky turntable implementation method: 1, create a PHP example file; 2, through the code "function get_gift () {...}" to achieve the big turntable lottery algorithm.

This article operating environment: Windows7 system, PHP7.4 version, Dell G3 computer.

How to realize the code of php lucky turntable?

PHP realizes the lottery algorithm of large turntable

Code:

Function get_gift () {/ / assemble award array / / award id, prize Probabilities $prize_arr = array ('0' = > array ('id'= > 1graded priority = >' tablet', 'vault = > 0),' 1' = > array ('id'= > 2reign primer = >' digital camera', 'vault = > 1),' 2' = > array ('id'= > 3prizekeeper = >' speaker device', 'vault = > 1) '3' = > array (' id'= > 4 camera prizecards = > 4G flash drive', 'vault = > 1),' 4' = > array ('id'= > 5 camera prizecards = >' 10Q coins', 'vicious = > 1),' 5' = > array ('id'= > 6 prizecards = >' empty prizes', 'vests = > 6),) Foreach ($prize_arr as $key = > $val) {$arr [$val ['id']] = $val [' v']; / probability array} $rid = get_rand ($arr); / / id $res ['yes'] = $prize_arr [$rid-1] [' prize']; / / winning award unset ($prize_arr [$rid-1]) / / remove the winning prize from the array, leaving the unwon prize shuffle ($prize_arr); / / disrupt the array order for ($item0) / proCur) {$randNum = mt_rand (1, $proSum); / / return a random integer if ($randNum)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report