This lottery small program, in the actual test environment can also be used, for example, the test data query in the in condition, to query the random 5 ID, and then use AB to test
Copy CodeThe code is as follows:
/**
* "Lottery" function
*
* @param integer $first start number
* @param integer $last end number
* @param integer $total number of 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 is not in the array, it is added to the array
if (count ($winner) = = $total) break;
}
Return implode (", $winner);
}
For test
Echo Iswinner (1, 100, 5);
?>
http://www.bkjia.com/PHPjc/327707.html www.bkjia.com true http://www.bkjia.com/PHPjc/327707.html techarticle This lottery small program, in the actual test environment can also be used, for example, the test data query in the in condition, to query the random 5 ID, and then use AB to pressure test copy code generation ...