欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php遞歸遍歷刪除文件的方法

 更新時間:2015年04月17日 12:11:14   作者:不吃皮蛋  
這篇文章主要介紹了php遞歸遍歷刪除文件的方法,涉及php遍歷文件操作的相關(guān)技巧,非常具有實用價值,需要的朋友可以參考下

本文實例講述了php遞歸遍歷刪除文件的方法。分享給大家供大家參考。具體如下:

這個函數(shù)稍加修改就可以變成一個遞歸文件拷貝函數(shù)

<?php
function 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程序設(shè)計有所幫助。

相關(guān)文章

最新評論