I need a way to randomly include a file from a directory. It has to be random but over the course of the day they need to be displayed equally.
I’ve tried this but i can’t get it to work and its just random not random but equal
<?
$path = ‘thanksgiving/includes’; // remeber trailing slash!
$handle = opendir ($path);
while (($filename = readdir ($handle)) !== false)
{
if ($filename != ‘.’ && $filename != ‘…’)
{
$file_array[] = $filename;
}
}
$rand = rand (0, count ($file_array));
include ($path . $file_array[$rand]);
?>
I would like to use file_get_contents in the include if that would be possible
Any help would be appreciated.