Jump to content

Image Rotation


brmcdani

Recommended Posts

I have a simple image array that is being called to rotate images.  I need to assign some ahref values to the images.  How would I go about this?  I would guess add the url to the array.  Any ideas would be appreciated here is my code:

 

<?php
function randomImage ( $array ) {
$total = count($array);
$call = rand(0,$total-1);
return $array[$call];
}

$my_images = array (
"banners/1.jpg",
"banners/2.jpg",
"banners/3.jpg",
"banners/4.jpg",
"banners/5.jpg",
"banners/6.jpg",
);

echo '<img
src="'.randomImage($my_images).'";
alt="Random Image" />';
?>

Link to comment
https://forums.phpfreaks.com/topic/202295-image-rotation/
Share on other sites

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.