[UPHPU] Random images from multiple files

Wade Preston Shearer lists at wadeshearer.com
Thu Jul 12 09:11:11 MDT 2007


> There are 17 folders each with around 10 images named 1.jpg, 2.jpg,  
> ect. so
> that when I update the images they are in the correct order.

If you can control the number of files in the folders and what they  
are named then this is simple (otherwise you would have to write the  
logic that reads the directory).

Something like this would do the trick:

<?php

$photographers = array('bob','tony','brett','susan','mike','ashley',
	'mark','hope','clair','matt','luke','john','ernie','bert','bryson',
	'ryan','timothy');

$rand_photographer = $photographers[array_rand($photographers)];

$rand_photograph = rand(1,10);

$rand_photo_path = '/' . $rand_photographer . '/' .  
$rand_photograph . '.jpg';

echo $rand_photo_path;

?>

<img src="<?php echo $rand_photo_path; ?>" />
	

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2425 bytes
Desc: not available
Url : http://uphpu.org/pipermail/uphpu/attachments/20070712/46f1f802/smime.bin


More information about the UPHPU mailing list