Home  >  Article  >  php教程  >  循环读取目录中的文件

循环读取目录中的文件

PHP中文网
PHP中文网Original
2016-05-25 17:02:081278browse

php代码

header("Content-type:text/html;charset=utf-8;");
set_time_limit(0);
$dir_ = dirname(__FILE__)."/tmp/";
$dest = dirname(__FILE__)."/dir/";

$dread = opendir($dir_);
while(false != ($df = readdir($dread)))
{
	if($df != "." && $df != ".."){
		if(is_dir($dir_.$df)){
			echo "======".$df."======"."
";
			echo dirs($dir_.$df."/")."
";
		}
	}
}
function dirs($d)
{
	global $dest;
	$od = opendir($d);
	while(false != ($ddf = readdir($od)))
	{
		if($ddf != "." && $ddf != ".."){
			copy($d.$ddf,$dest.$ddf);
		}
	}
	
}

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