您好,欢迎访问一九零五行业门户网

php读取目录、文件并显示的函数_PHP教程

读取指定的目录,并显示其中的文件个数和文件名。
/*
this script read the filenames from a specified directory and returns them in an array.
*/
function searchdir($basedir)
{
global $filelisting, $number; //defines the two variables as global so they can be accessed
unset($filelisting); //kills $filelisting in case it have been used earlier in the
unset($number); //same as above
$handle=opendir($basedir);
while ($file = readdir($handle)) {
if ($file==. or $file==..) {
} else {
$filelisting[]=$basedir$file;
};
};
$number=sizeof($filelisting); //取得文件个数
};
searchdir(.); //runs the function to search the current directory
echo $filelisting[1]; //echos the second value in the array
echo $number; //echos the size of the array
?>
http://www.bkjia.com/phpjc/532221.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/532221.htmltecharticle读取指定的目录,并显示其中的文件个数和文件名。 /* this script read the filenames from a specified directory and returns them in an array. */ function searchd...
其它类似信息

推荐信息