[UPHPU] Random images from multiple files

Jonathan Duncan jonathan at bluesunhosting.com
Thu Jul 12 09:42:24 MDT 2007


On 12 Jul 2007, at 08:56, Jacob Wright wrote:

> You could keep a database or xml file or even just a text file with  
> a list
> of all the images. Your PHP could grab the list, throw it into an  
> array, and
> use array_rand() on it
>
> Jacob
>

I was first thinking of reading all the directories and then picking  
one at random, then reading all the filenames in that directory and  
then picking one at random.  It would work, but it is slower (slow  
being a relative term).  However, I like Jacob's idea better.   
Keeping track of each photo in the database is helpful for many more  
reasons than just this one.

Jonathan




More information about the UPHPU mailing list