Zo selecteer ik een random file uit een dir, maar het komt heel vaak voor dat ie hetzelfde bestandje uit de file pakt, weet iemand hier een oplossing voor?
$dirarray = array();
if ($dir = @opendir($url)) {
while($file = readdir($dir)) {
if ($file <> ".." AND $file <> "." AND $file <> "geenfoto.gif"){
array_push($dirarray,$file);
}
}
}
closedir($dir);
$rndfile = array_rand($dirarray);
$images = split("_", $dirarray[$rndfile]);
$a_id = $images[0];
$dirarray = array();
if ($dir = @opendir($url)) {
while($file = readdir($dir)) {
if ($file <> ".." AND $file <> "." AND $file <> "geenfoto.gif"){
array_push($dirarray,$file);
}
}
}
closedir($dir);
$rndfile = array_rand($dirarray);
$images = split("_", $dirarray[$rndfile]);
$a_id = $images[0];