Posted by Iain on 10/02/05 22:06
I have been using rand() and mt_rand() to give a bit of dynamic content to a
site...basically selecting one of a number of pictures at random. Each
refresh then gives a slightly differnt page as in...
$images = array (
"<img src=\"/image1.jpg\"">",
"<img src=\"/images2.jpg\"">",
"<img src=\"/images3.jpg\"">"
);
$picture = $images[mt_rand(0,2)];
print ("$picture");
What I find is that on a Windows dev platform both rand() and mt_rand()
*always* give the max value - 2 in this case - and on a Linux platform seem
to have a 'preference' for the max value. Any ideas why? Neither seem must
of a random function especially on Windows!
Thx.../Iain
Navigation:
[Reply to this message]
|