note 15060 added to function.rand.php
| From: | jamesmc at php2 dot chek dot com | Date: | Sun, 26 Aug 2001 07:06:24 +0000 |
| Subject: | note 15060 added to function.rand.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17151@lists.php.net to get a copy of this message | ||
A simple random image grabber, using srand() and rand() functions.
<?
$img = array("linux.gif","sun.gif","debian.gif");
srand ((float) microtime() * 1000000);
$randval = rand(0,2);
print"<img src=$img[$randval]>";
?>
Substitue the images in the array, and change the values in the rand() funtion - you will be all
set! Works better with more images!
http://www.php.net/manual/en/function.rand.php