Reply to rand() and mt_rand()

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация