PHP Random picture from folder
Random picture from folder
<?
$dir = "Summer";
function smqtai($dir, $sbor, $rez) {
$handle = opendir($dir);
while($file = readdir($handle)) {
if ($file == "." || $file == ".." || $file == "Thumbs.db" || is_dir("$dir/$file")) { }
else {
$sbor = $sbor+1;
if ($sbor == $rez) { echo "<IMG SRC='$dir/$file'>"; }
}
}
return $sbor;
closedir($handle);
}
if (is_dir($dir)) {
$tot = smqtai($dir, "0", "");
$nom = rand(1,$tot);
$tot = smqtai($dir, "0", "$nom");
}
?>