I have a directory which contains several text files. What I'm trying to do is to randomly select one of the files and then display it. Here's what i got so far, but i still haven't managed to get it working. Any idea's? Thanks.
<?php
function random_pic($dir = 'wp-content\files')
{
$files = opendir($dir . '/*.txt');
$file = array_rand($files);
return $files[$file];
}
while(!feof($file)) {
echo fgets($file) . "<br />";
}
fclose($file);
?>