Rotating Banner in PHP
This is a snippet that will rotate a banner on a page. All you have to do is set $File and $Images to the paths to the images. It will just do the next image in $Images in order. It doesn’t rotate banners for seperate users, it just goes through. Before you use it, create the $Stat file and set the contents of it to 0 and your ready to go!
<?php
$File = 'Banner.txt';
$Images[] = 'Banner_1.gif';
$Images[] = 'Banner_2.gif';
$Images[] = 'Banner_3.gif';
$fp = fopen($File, 'r');
$Stat = fread($fp, filesize($File));
fclose($fp);
if($Stat >= count($Images)) $Stat = 0;
echo $Images[$Stat];
$Stat++;
$fp = fopen($File, 'w');
fwrite($fp, $Stat);
fclose($fp);
?>