Posted by Domestos on 04/23/06 04:19
A less computationally expensive method of accomplishing the same thing is
to use the mt_rand() function. This function uses the Mersenne Twister
algorithm and is considerably faster than rand(). In addition as of PHP
version 4.2.0 there is no need to seed the mt_rand() random number generator
with srand() or mt_srand()
<?php
// Range of numbers
// Minimum number
$min = "1";
// Maximum number
$max = "10";
echo "mt_rand() Mersenne Twister pseudo-random number: ".
mt_rand($min, $max);
?>
Navigation:
[Reply to this message]
|