search
Homephp教程php手册中奖率算法,方便修改中奖率

如果有更好的,可以互相交流多谢 优势:新增和删除奖项以及修改概率都很方便。 公式:随机数=(概率+前面所有概率)*总数 WCMS ?php//配置说明//$gailv 1为1等奖的概率,2为等奖的概率//$base 为基数 百分之几概率 //@autor wolf Email 116311316@qq.com//概率算

如果有更好的,可以互相交流 多谢  
优势:新增和删除奖项以及修改概率都很方便。
公式:随机数 .CodeEntity .code_pieces ul.piece_anchor{width:25px;position:absolute;top:25px;left:-30px;z-index:1000;} .CodeEntity .code_pieces ul.piece_anchor li{width:25px;background: #efe;margin-bottom:2px;} .CodeEntity .code_pieces ul.piece_anchor li{border-left:3px #40AA63 solid;border-right:3px #efe solid;} .CodeEntity .code_pieces ul.piece_anchor li:hover{border-right:3px #40AA63 solid;border-left:3px #efe solid;} .CodeEntity .code_pieces ul.piece_anchor li a{color: #333;padding: 3px 10px;} .CodeEntity .code_pieces .jump_to_code{visibility:hidden;position:relative;} .CodeEntity .code_pieces .code_piece:hover .jump_to_code{visibility:visible;} .CodeEntity .code_pieces .code_piece:hover .jump_to_code a{text-decoration:none;} .CodeEntity .code_pieces h2 i{float:right;font-style:normal;font-weight:normal;} .CodeEntity .code_pieces h2 i a{font-size:9pt;background: #FFFFFF;color:#00A;padding: 2px 5px;text-decoration:none;}
<?php
//配置说明
//$gailv 1为1等奖的概率,2为等奖的概率
//$base 为基数 百分之几概率 
//@autor wolf Email 116311316@qq.com
//概率算法
$gailv = array (1 => 0.02, 2 => 0.1, 3 => 0.3, 4 => 0.5, 0 => NULL );

//根据最小的中奖率设置 百分比 千分比 万分比
$base = 100;
$randNum = rand ( 1, $base );

$reward = 0; //默认不中奖 几等奖
//随机数<=(概率+前面所有概率)*总数
$before = 0;
foreach ( $gailv as $k => $v ) {
	if ($randNum <= ($v + $before) * $base) {
		$reward = $k;
		break;
	}
	$before += $v;

}
echo $reward;
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)