function getImgDir($path)
{
$ret = Array();
if($dir = @opendir($path))
{
while(($file = readdir($dir)) !== false)
if(substr($file, 0, 1) != ".") //screens files that start with ".", like hidden files and files "." and ".."
$ret[] = $file;
closedir($dir);
}
return $ret;
}
$pics = getImgDir("covers"); //dir with all pics
srand((double)microtime()*1000000); //starts the rand thing or something...
$selectedpic = $pics[rand(0,sizeof($pics)-1)];
print " \n";
?>
|