Ok so I spent like 3 hours looking for an uber simple effective php rotating script... and really couldn't find any! What I needed was something that could rotate html randomly while being very small file wise. So i'll share it here. <? $banners = split("<!-- SPLIT -->", preg_replace("/<\?.*?\?>/", "", file_get_contents("/complete route to directory/rotatelist.txt"))); echo $banners[rand(0,sizeof($banners) - 1)]; ?> PHP: First you put the above in your index.php file or whatever... Then you create a rotatelist.txt file and include what ever info you need to be rotated (banners, img's, html). Just put a hard return and <!-- SPLIT --> in between whatever you want rotated. Again super simple and useful. and make sure to put the filepath from your root into the rotatelist.txt.
You could always just delimit each with a new line, then explode( "\r\n", $file_contents) (Important note: "\r\n" must be wrapped in " not ', otherwise the linebreak won't be considered a linebreak, just those literal charchters) Shaves a few bytes of your banners.txt too.
I tried this and for me it simply rotates a text display of the file names I list in the text file rather than incorporating their respective code into the html that the php generates. Still useful for this purpose, but how do I get the file contents to be rotated?
you have to put the actual code into the file... not the filenames then use the <!-- SPLIT --> and a hard return each time you want new stuff