![]() |
Help With Simple Rotation Script? Hey guys, I've Googled, not much of a programmer. I'm looking for a simple PHP or javascript code that I can place on a site to rotate one image 25% of the time and the second 75% of the time. I would assume this is just a few simple lines of code, maybe I'm wrong. Any links to something like this or ideas? Thanks in advance! -Scott |
Re: Help With Simple Rotation Script? The following is based on randomization, which means it is not at all guaranteed to be 25% and 75% in the short term. But over time the 1-in-4 odds will even out. $random_images = array(); $random_images[] = 'imageA.jpg'; $random_images[] = 'imageA.jpg'; $random_images[] = 'imageA.jpg'; $random_images[] = 'imageB.jpg'; // this is the ~25% file name shuffle($random_images); // randomize the order of the above files echo '<img src="path/to/images/'.$random_images[0].'" />'; // print out the first random one -Ryan |
Re: Help With Simple Rotation Script? Sweet! Thanks Ryan. Going to try it out now. -Scott |
Re: Help With Simple Rotation Script? |
| All times are GMT -6. The time now is 10:27 PM. |