Probabilistic calculation PHP Lucky Star _php Tutorial

Source: Internet
Author: User
Given a probability (here is the number of points), determine whether an event occurred.
can be used in accordance with the number of points earned by the user, randomly generated site lucky Star and other aspects (note: There is a word).
/**
@title:P hp Lucky Star (Lucker)
@version: 1.00
@license: BSD
@author: Axgle
*/

$BL = Lucker (50); possibility of//50%
Var_dump ($BL);

function Lucker ($dot) {
$dot = Intval ($dot);
$dot = max ($dot, 0);//min dot = 0
$dot = min ($dot, +);//max dot = 100

$one = rand (1,100);
$total = range (1,100);
Shuffle ($total);

$range = Array ();
for ($i =0; $i < $dot; $i + +) {
$range [] = $total [$i];
}
Return In_array ($one, $range);
}
?>

http://www.bkjia.com/PHPjc/508501.html www.bkjia.com true http://www.bkjia.com/PHPjc/508501.html techarticle given a probability (here is the number of points), determine whether an event occurred. Can be used in accordance with the number of points earned by users, randomly generated sites such as the Lucky Star (note: there is a word). PHP/* ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.