Home >php教程 >PHP源码 >scandir得到该文件下的所有文件和文件夹

scandir得到该文件下的所有文件和文件夹

PHP中文网
PHP中文网Original
2016-05-26 08:18:271226browse

php代码

<?php
$dir = "."; //当前目录
list_file($dir);

function list_file($dir){
	$list = scandir($dir); // scandir得到该文件下的所有文件和文件夹
	foreach($list as $file){//遍历
		$file_location=$dir."/".$file;//生成路径
		if(is_dir($file_location) && $file!="." &&$file!=".."){ //判断是不是文件夹
			echo "------------------------sign in $file_location------------------<BR>";
			list_file($file_location); //继续遍历
		}
		echo $dir."/".$file."<br/>";
	}
}
?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:QQ音乐APINext article:php 字符串与二进制互转