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_loc<span>%本文来源gaodai#ma#com搞*代#码9网#</span><strong>搞gaodaima代码</strong>ation------------------";list_file($file_location); //继续遍历}echo "<br/>";}}?>
以上就是php scandir()函数遍历文件夹目录和所有文件实例代码的详细内容,更多请关注搞代码gaodaima其它相关文章!