Specify a probability (here is the number of points) to determine whether an event has occurred. it can be used to randomly generate website lucky stars based on the number of points you get (note: There is a word here ). & lt ;? Php/** @ title: PHP lucker @ version: 1.00 @ license: BSD @ author: axgle */$ bllu
Specify a probability (here is the number of points) to determine whether an event has occurred.
It can be used to randomly generate website lucky stars based on the number of points you get (note: There is a word here ).
/**
@ Title: PHP Lucky Star (lucker)
@ Version: 1.00
@ License: BSD
@ Author: axgle
*/
$ Bl = lucker (50); // 50% likelihood
Var_dump ($ bl );
Function lucker ($ dot ){
$ Dot = intval ($ dot );
$ Dot = max ($ dot, 0); // min dot = 0
$ Dot = min ($ dot, 100); // max dot = 100
$ One = revert (1,100 );
$ Total = range (1, 1,100 );
Shuffle ($ total );
$ Range = array ();
For ($ I = 0; $ I <$ dot; $ I ++ ){
$ Range [] = $ total [$ I];
}
Return in_array ($ one, $ range );
}
?>