Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199901

[PHP3] strange problem with rand() From: Hans Westerbeek (hw <email protected>)
Date: 01/31/99

hi all,

I am using PHP on FreeBSD (i am a Pair networks client)
and i have a strange problem, look at this:

$images = array("batman","indian","mermaid");
/* images array made shorter, doesn't seem to make a difference to me */
$count = count($images);
srand((double)microtime()*1000000); //seeding the random generator
$i=rand(0,$count); //picking a value between 0 and the length of $images

----

After this I just do something like: <img src="<? print $images[i]; ?>.gif"

After this a random image from the array should appear. But all i get is HUGE values for $i like 1543769270 or 470447945 (i know this because I print $i in my php3 file)... Anybody know what's going on?

Byebye, Hans

-- PHP 3 Mailing List http://www.php.net/ To unsubscribe send an empty message to php3-unsubscribe <email protected> To subscribe to the digest list: php3-digest-subscribe <email protected> For help: php3-help <email protected> Archive: http://www.php.net/mailsearch.php3 List administrator: zeev-list-admin <email protected>