Home  >  Article  >  Backend Development  >  php 复制索引,但目录下的子目录及文件没有复制

php 复制索引,但目录下的子目录及文件没有复制

WBOY
WBOYOriginal
2016-06-13 12:38:23779browse

php 复制目录,但目录下的子目录及文件没有复制?

copy_module_file("123","345",array('1','2','3','4'));	<br />
<br />
function copy_module_file($path,$newp,$ex){<br />
	if(!is_dir($newp)){<br />
		mkdir($newp);<br />
	}<br />
	if (file_exists($path)){<br />
		if(is_file($path)){<br />
			copy($path,$newp);<br />
		} else{<br />
			$handle = opendir($path);<br />
			while (($file = readdir($handle))!='') {<br />
				if (($file!=".") && ($file!="..") && ($file!="")){<br />
					if (is_dir("$path/$file") && in_array($file,$ex)){  //后面一段是复制指定目录<br />
						copy_module_file("$path/$file","$newp/$file");<br />
					} else{<br />
						copy("$path/$file","$newp/$file");<br />
					}<br />
				}<br />
			}<br />
			closedir($handle);<br />
		}<br />
	}<br />
}

如果123这个目录下,有1-100个目录,目录下有什么不同的目录,但我想要把123里面的1,2,3,4目录包括目录里的文件复制到345这个目录里,这段php应该怎么再改一下??

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