# snippet is free and open, just don't take credit for it
# as your own. philip olson , theprojects.org
# debugged by Jim Hawley in phpbuilder support forum (thanks jim!)
$dir = "IOD/"; // where your images are
function Get_Image_list($dir) {
if(!$dir) {
$dir = ".";
}
$file_array = array();
$dir_handle = opendir($dir);
$a = 0;
while($file = readdir($dir_handle)) {
if((preg_match('/jpg/',$file)) || // can add more here
(preg_match('/png/',$file)) || // or take some away
(preg_match('/gif/',$file)) ||
(preg_match('/jpeg/',$file))) {
$file_array[$a] = $file;
$a++;
}
}
return $file_array;
}
$files = Get_Image_list($dir);
$max = count($files)-1;
srand((double)microtime()*1000000);
$index = rand(0,$max);
$image_name = $files[$index];
?>
">