View Single Post
Old 09-26-2011, 04:04 AM   PM User | #2
ASTP001
New Coder

 
Join Date: Aug 2011
Posts: 51
Thanks: 6
Thanked 12 Times in 12 Posts
ASTP001 is an unknown quantity at this point
you can get an array of all the images in that folder by calling the function scandir and then count the number of arrays in it and call rand function to make it randomly pick...

PHP Code:
$images scandir('/images');
$img_num count($images);
$rand rand(2,$img_num); //min is 2 because scandir includes current directory and the directory above
echo "<img src={$images[$rand]}>"
ASTP001 is offline   Reply With Quote
Users who have thanked ASTP001 for this post:
jewradly (09-26-2011)