View Full Version : changeing image.....

02-26-2003, 02:53 AM
is there a php that changes an image......the main banner, say, every time the page is viewed?

02-26-2003, 03:49 AM
Yeah, I use this randomising script for a similar purpose:
$array[200]; //--number of banners/images
$elem = 0;
$dirname = "images"; //--insert the name of the banner, in this example a file named "images" in the same directory as the rotation script
$dh = opendir($dirname);
while ($file = readdir($dh)) {
if (!is_dir("$dirname/$file"))
$array[$elem] = $file;
$elem = $elem + 1;

srand((double)microtime() * 10000000);
$rand_keys = array_rand($array);
$temp = $array[$rand_keys];

header("Location: $dirname/$temp");

?> Then just link as so: <img src="filename.php"/>.

02-26-2003, 11:57 AM
well, array_rand was a new one for me, looks like that'll be quite useful. :)