PHP头条
热点:

随机取图的PHP代码


// 用法
// include("ranimage.php");
// 或者
// 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("");
?>

www.phpzy.comtrue/phprm/39380.htmlTechArticle随机取图的PHP代码 // 用法 // include("ranimage.php"); // 或者 // require "ranimage.php"; $dir = DownloadFilesa2001-12-13; function Get_Image_list($dir) { if(!$dir) { $dir = "."; } $file_array = array(); $dir_handle = opendir($dir...

相关文章

    暂无相关文章

PHP之友评论

今天推荐