PHP Tutorial : Random Banner Rotator

Hi,

In this php tutorial you will learn how to build a random image banner rotator. Basically, it’s the same as the link rotator, we build a php array with images wanted to rotate, then we’ll apply the rand() php function.

<?php
$banners = array("path/img1.jpg", "path/img2.gif");
$max = sizeof($banners);
$rand = rand(0, $max);
print $banners[$rand];
?>
This entry was posted in Usefull PHP and tagged , , . Bookmark the permalink.

3 Responses to PHP Tutorial : Random Banner Rotator

  1. Mobile Phone Line Rental Deals says:

    Hi,

    This is great blog and has answered many of my questions. Just one other question with this php script.

    I have an affiliate website to do with mobile phone deals and so on. I have dedicated a small section for banners but I want to rotate the banners I have like this code does, but this code does not allow for the link in the banner.

    How can this script be modified such that I can use banners from affiliate programs?

    Asim

  2. Message Forum says:

    Thanks for this wonderful script, i am going to use this in my forum. is it will work in my forum.

  3. admin says:

    You guys start thinking I just give guidelines and start scripts, adapt it for your own needs or rent my php services to do it for you! No freebies!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>