Jump to content

Random image rotator... php or java?


brax

Recommended Posts

I found random PHP slideshow script... but can't find where PHP can set up an array with n images and one and only one url for each rotatated image...  can PHP do this?  Or am I stuck with Java?  Or what?

 

automated script in html code for image rotate... url link also

 

array has images and url for link

 

automated pulls image and link from array

 

random and non-repeating.... once per page view.

 

Steer this ship.  PHP or Java?  Thanks.

Link to comment
https://forums.phpfreaks.com/topic/54504-random-image-rotator-php-or-java/
Share on other sites

You'd need an array containing all of the images (I think)

for example:

$images = array(0 => 'myimage.gif', 1 => 'myimage2.gif);

Then have a variable which is set at a random number between 0 and the amount in the variable.

$no = rand(0, count($images));

 

Then call the image like this:

<?php
echo '<img src="' . $images[$no] . '" border="0" width="100" height="100" alt="' . $images[$no] . '" />
?>

 

This was just made up very quickly so might be completly wrong, but it's what I'd try first...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.