'; $handler = opendir($this_dir); // keep going until all files in directory have been read while ($file = readdir($handler)) { if ($file != '.' && $file != '..') { $file_extension = strtolower(substr($file, -4)); //extension of this file //echo "file_extension is: ".$file_extension."
"; if (preg_match($extensions, $file_extension)) { //displayable found... proceeding to store in array $displayables[] = $file; //echo "displayable: ".$file."
"; } } } // tidy up: close the handlers closedir($handler); //Now we randomize the array and randomly pick out 1 displayable shuffle($displayables); $place = $displayables[0]; //echo "place is: ".$place."
"; return $this_dir."/".$place; } ?>