Usage
Include ("ranimage.php");
Or
Require "ranimage.php";
$dir = downloadfilesa2001-12-13;
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)) | |
(Preg_match (/png/, $file)) | |
(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];
Echo ("");
?>
http://www.bkjia.com/PHPjc/532193.html www.bkjia.com true http://www.bkjia.com/PHPjc/532193.html techarticle / /usage//include ("ranimage.php");//or//require "ranimage.php"; $dir = downloadfilesa2001-12-13; function get_image _list ($dir) {if (! $dir) {$dir = ".";} $file _array = ...