Myspoonistoobig
all of those lines are unnecessary anyway.....PHP has array_rand() to pick a random element from an array. and as of php 4.2 (long time ago), you don't need to seed the random number generator
so really, it can be shortened to this:
<?php
$links = array("images","more images.jpg","blahblah.gif","myimage.png")
header('Location: ' . array_rand($links))
?>
If I didn't seed the random number generator, it wasn't very random. Like it would show the same image three or four times in a row.
confused
But it can be shortened that much? Cool.
smile
Edit: That didn't work.
razz It just tried to redirect to a random number in the directory the script was in, not the image 'assigned' that number. (IE it would redirect to http
://www.domain.com/sig/7 instead of http
://www.domain.com/sig/image7.png.) This works, though, and it feels a bit faster than the old code:
<?php
$links = array("images","more images.jpg","blahblah.gif","myimage.png")
$randNum = array_rand($links)
header("Location: ".$links[$randNum])
?>
Edit: Just out of curiosity, I tried this, and it worked, too:
<?php
$links = array(
"image.png",
"other-image.jpg",
"blahblah.gif",
"myimage.png"
)
header("Location: ".$links[array_rand($links)])
?>