Specify a probability (here is the number of points) to determine whether an event is generated. it can be used to randomly generate a website honor star based on the number of points the user receives (note: There is a word like 'here ).? Php/** @ title: PHP lucker @ version: 1.00 @ license: BSD @
Specify a probability (here is the number of points) to determine whether an event is generated.
It can be used to randomly generate a website honor star based on the number of points the user receives (note: There is a word like 'here ).
/**
@ Title: PHP 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 );
}
?>