Php implementation code of the lucky draw applet. This lucky draw applet can also be used in the actual test environment. for example, to query test data under the in condition, you need to query random five IDs, then copy the code to use AB to perform stress testing on behalf of this lucky draw applet, which can also be used in the actual test environment. for example, the query of test data is in, query the random five IDs, and then use AB to perform stress testing.
The code is as follows:
/**
* Lottery function
*
* @ Param integer $ first start number
* @ Param integer $ last end number
* @ Param integer $ total winners
*
* @ Return string
*
*/
Function isWinner ($ first, $ last, $ total)
{
$ Winner = array ();
For ($ I = 0; $ I ++)
{
$ Number = mt_rand ($ first, $ last );
If (! In_array ($ number, $ winner ))
$ Winner [] = $ number; // if the number does not exist in the array, add it to the array.
If (count ($ winner) ==$ total) break;
}
Return implode ('', $ winner );
}
// For test
Echo isWinner (1,100, 5 );
?>
Generation...