You are here: Random Images with no duplicates? « PHP « IT news, forums, messages
Random Images with no duplicates?

Posted by "Mike Rondeau" on 12/16/05 06:45

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

 

Navigation:

[Reply to this 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

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