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
?>

www.phpzy.comtrue/phprm/39573.htmlTechArticlephp读取目录、文件并显示的函数 读取指定的目录,并显示其中的文件个数和文件名。 /* This script read the filenames from a specified directory and returns them in an array. */ Function searchdir($basedir) { gl...

相关文章

    暂无相关文章

PHP之友评论

今天推荐