ScriptPlazzaon Google+

If you have more than one banner that you want to display on your site in random order use following snippet.

<?php
$ads = array();

$ads[] = '<a href="http://www.bannerurl1.com/"><img src="banner1.jpg"></a>';
$ads[] = '<a href="http://www.bannerurl2.com/"><img src="banner2.jpg"></a>';
$ads[] = '<a href="http://www.bannerurl3.com/"><img src="banner3.jpg"></a>';
$ads[] = '<a href="http://www.bannerurl4.com/"><img src="banner4.jpg"></a>';
$ads[] = '<a href="http://www.bannerurl5.com/"><img src="banner5.jpg"></a>';

shuffle($ads);
echo $ads[0];
echo $ads[1];
echo $ads[2];
echo $ads[3];
echo $ads[4];
?>
 

Leave a Comment

You must be logged in to post a Review.