View Single Post
Re: a different sig each time
Old
  (#30)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: a different sig each time - 13-05-2004

@Frosty: About the "rand (0, $file_count - 1)", I suppose the array indexing works just like in C ?
Let's say we have an array of 3 elements (hence $file_count = 3)
we have
array[0] -> first element
array[1] -> second element
array[2] -> third element (and no array[3], which is out of bounds)
is that right ?
so if I want to pick a random number between 0 and 2 inclusively, I call rand (0, $file_list - 1)... well that's how I see things, but you know PHP better than me so... ???

@SF: with this script you have to arrange your pics into subdirectories, because it takes the whole image list.
If you want a script that would output only a selected set of images randomly, you can write something like this:
Code:
<?php 

$files = Array("image1.gif", "image2.jpeg", "image3.png"); // list of files
$file_count = 3; // number of files to choose from

// take one file randomly among the list and send it away
readfile ($files[rand (0, $file_count - 1)]);

?>



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote