SoyDelicious
Technical User
Objective:
Create a array from files in directory, then use array_rand() to randomly pick one of these files, of which will be used to reflect an image onto our CMS. While doing so I need to filter the array for listings like "." or "..". Presently it does indeed randomize the output although it doesn't pick one, which is very disaapointing. Thanks for your time. If someone does have a second to help if you could be as verbose as possible so that I can learn from this.
Below is code.
//handle checkin that shit out
$handle = opendir('./classes');
while (false !== ($file = readdir($handle))) {
$files[] = $file;
$count = count($files);
srand((float) microtime() * 10000000);
$rand_keys = array_rand($files, $count);
print $files[$rand_keys[0]] . "\n";
}
closedir($handle);
Create a array from files in directory, then use array_rand() to randomly pick one of these files, of which will be used to reflect an image onto our CMS. While doing so I need to filter the array for listings like "." or "..". Presently it does indeed randomize the output although it doesn't pick one, which is very disaapointing. Thanks for your time. If someone does have a second to help if you could be as verbose as possible so that I can learn from this.
Below is code.
//handle checkin that shit out
$handle = opendir('./classes');
while (false !== ($file = readdir($handle))) {
$files[] = $file;
$count = count($files);
srand((float) microtime() * 10000000);
$rand_keys = array_rand($files, $count);
print $files[$rand_keys[0]] . "\n";
}
closedir($handle);