这篇文章主要介绍了php递归遍历删除文件的方法,涉及php遍历文件操作的相关技巧,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了php递归遍历删除文件的方法。具体如下:
这个函数稍加修改就可以变成一个递归文件拷贝函数
<?phpfunction mover($src,$dst) {$handle=opendir($src);// opens source dir.if (!is_dir($dst)) mkdir($dst,0755);// make dest dir.while ($file = readdir($handle)) { if (($file!=".") and ($file!="..")) { // skips . and .. dirs $srcm=$src."/".$file; $dstm=$dst."/".$file; if (is_dir($srcm)) { // if another dir is found mover($srcm,$dstm); // calls itself - recursive wtg } else { copy($srcm,$dstm); unlink($srcm); // is just a copy procedure is needed } // comment out this line }}closedir($handle);rmdir($src);}?>
总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。
相关推荐:
php中实现数组生成要执行的sql语句
php针对文件操作及字符串加密的方法
php中mysql实现的增删改查功能
以上就是php递归函数遍历删除文件的方法的详细内容。