Help With Simple Rotation Script?

3 replies
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
#rotation #script #simple
  • Profile picture of the author theIMgeek
    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
    Signature
    FREE WSO: Protect and Automatically Deliver Your Digital Products

    Ask the Internet Marketing Geek
    <-- Happy to help with technical challenges
    MiniSiteMaker.org <-- Free software to make your mini-sites fast and easy
    {{ DiscussionBoard.errors[2004535].message }}
  • Profile picture of the author Scott Murdaugh
    Sweet! Thanks Ryan.

    Going to try it out now.

    -Scott
    Signature

    Over $30 Million In Marketing Data And A Decade Of Consistently Generating Breakthrough Results - Ask How My Unique Approach To Copy Typically Outsells Traditional Ads By Up To 29x Or More...

    {{ DiscussionBoard.errors[2004618].message }}
  • {{ DiscussionBoard.errors[2006766].message }}

Trending Topics