Help w/ rotate item syntax

yesterday, I posted a question into the general programming thrread. today, I actually have code to troubleshoot.

I’m trying to cycle some html docs on pageload. I found a chunk of code that cycles images based on a time hash. code is

<?php  $i = (bcmod(intval(time()),60)) % 6;
print '<img src="images/header_image' . $i . '.jpg" style="float:right;" />'
?>

I’d like to modify that to pull html files into an iframe, but so far, I’m getting the syntax wrong (or I’m trying to use a screwdrive to hammer in a nail)

Any advice?

<?php $i = (bcmod(intval(time()),60)) % 6;
print '<iframe src="directory/filename' . $i . '.html" />'
?>

If its one of 10 random file names you want you can do this;


echo rand(1,10) . '.html' ;

//e.g. 7.html

or if you have an array of real file names;


$a = array('this.html', 'that.html');

$key = array_rand($a ) ;

echo $a[$key];

//e.g. that.html

The second could be better because you could populate the array $a from the contents of a given folder. Drop a new file into the folder and it gets put into the array.

Is this what you are after though, a totally random selection CAN appear twice in succession.