Random Images with no duplicates?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm still very green with PHP, but am working to fix that.

I've searched high and low for an answer to this question and so far
no solution has presented itself. I have a script to populate my web page
with random images:

<?php
#random images example
#this is your file
$file = "images.txt";
#open the file
$openFile = file($file);
#generate a random number
srand((double)microtime()*1000000);
#get one of the entries in the file
$random_image = $openFile[array_rand($openFile)];
#display the entry
echo "<img src='$random_image' height='170' width='100'></img>";
?>


This works beautifully, but my problem is that sometimes, the same image
displays twice or more on the same page-load. My page requires 10 different
places where my images need to load, but I can't have any duplicate images 
show up.

Any suggestions on what I need to modify here?

Thanks in advance!
Mike 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux