By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

PHP Banner Rotation Script

Tutorial showing how to create a banner rotation script with PHP.

Edited: 2012-07-21 09:18

Before you read the Tutorial about Banner Rotation, it is recommended that you read Variables in PHP Which includes information about Array's, and finally String Concatenation.

Creating The Script

Can also be used to rotate images

The first Example is really simple, and sufficient in most cases.


$RandomNumber = rand(1, 10);

echo '<img src="Images/' . $RandomNumber . 'img.jpg">';


The above asume that you already know the name of the images, simply name each image "1img.jpg, 2img.jpg, 3img.jpg" Etc. And then increase the random number accordingly.