0

I have a list of say 15 images.

How can I make it so that in each page refresh they all change to a random position?

Thanks

3
Contributors
10
Replies
11
Views
6 Years
Discussion Span
Last Post by BleepyE
Featured Replies
  • 1
    diafol 3,720   6 Years Ago

    Place locations into a multidimensional array (positions - X, Y coords). Place images into an array. You can use shuffle to shuffle the image arrangement. Place an image to a position via a loop. Read More

1

Place locations into a multidimensional array (positions - X, Y coords).
Place images into an array.
You can use shuffle to shuffle the image arrangement.
Place an image to a position via a loop.

Edited by diafol: n/a

0

Ahem...

You can use shuffle to shuffle the image arrangement.

0

Ok, I'm maybe I should rephrase.

I want to change the order of the images not the physical positions.

Would I still use shuffle?

0

Depends - are you showing all of them or just one?

If all, use shuffle on the array.

If just one, use mt_rand() too generate a random number between 0 and num photos - 1 and use that in conjunction with your array to get an image. Else you could divide the days of the week/month up between the images, so a diff image shows depending on the day/daynumber.

0

Heres the code I used;

<?php
$images=array( "1.gif","2.gif","3.gif","4.gif","5.gif"  );
shuffle($images);
for ($i=0;$i<5;++$i)
 echo "<img src='$images[$i]'>";
?>

You recon instead of the image names (1.gif etc) I could use the source code, because I need each image to hold a link.

Example:
Instead of 1.gif, <a href=".../contact.html"><img src=".../1.gif"></a>

Would that work?

0

This doesnt seem to work.

Any ideas on how I can shuffle the images and get them to link to a differnet pages?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.