I have an old script that I do not recall where I got it but would like to enhance it. I thought of creating multiple ones and just give them different names but that seems redundant and certainly less elegant than doing it in one script.
I have 5 images running down each side of a wordpress site (left & right sidebar) though the platform is not relevant in this application, I don't think... I want to be able to randomize each of those 10 images on each page so that each time a user visits the page or refreshes all the images change.
Is there a way to randomize all those images without special casing each one like the code I have and my lack of PHP knowledge would dictate?
$cpics = array (
"images/pic1.jpg",
"images/pic2.jpg",
"images/pic3.jpg"
);
$index = rand(0, 2);
$cbanner = $cpics[$index];
And then on the page I put
<img src="$cbanner">
So with my lack of PHP programming skills I would create an array for each location giving each array a different name so that my sidebar code would look like this:
<li><img src="$1banner"></li>
<img src="$2banner">
<img src="$3banner">
<img src="$4banner">
<img src="$5banner">
Thanks very much for your help.