gongzhonghao.png
扫码关注我们
最新赞助活动温馨提示:自愿赞助服务器费用,学生和没有工作的整站资源免费下载!
头像

php scandir()函数遍历文件夹目录和所有文件实例代码

来源:http://erdangjiade.com/topic/1875.html 你好,世界。 2017-09-25 22:42浏览(25)

scandir() 函数返回指定目录中的文件和目录的数组。

下面使用php scandir函数遍历文件夹目录和所有文件,代码如下:

<?php
$dir = "."; //当前目录
list_file($dir);
function list_file($dir){
$list = scandir($dir); // 得到该文件下的所有文件和文件夹
foreach($list as $file){//遍历
$file_location=$dir."/".$file;//生成路径
if(is_dir($file_location) && $file!="." &&$file!=".."){ //判断是不是文件夹
echo "------------------------sign in $file_location------------------";
list_file($file_location); //继续遍历
}
echo "<br/>";
}
}
?>

以上就是php scandir()函数遍历文件夹目录和所有文件实例代码的详细内容,更多请关注二当家的素材网其它相关文章!

评论0
头像

友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群

1 2