RE: Delete all files in DIR every 20 days

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello 

take a look a the Pear File_Find class

     require_once 'File/Find.php';
     $fs = new File_Find;
     $data = $fs->maptree('my_dir');

     $data[0] contains all directorys
     $data[1] all files 

     $ok = 0;
     $err = 0;
     foreach ($data[1] as $key)
     {
       if (unlink($key)) {
        $ok++;
       } else {
         $err++;
       }
     }

     if there is an error ist is not able to delete the directorys

   // the first directory (in deep) must the last one
   sort($data[0]);

    foreach ($data[0] as $key)
    {
      if(rmdir($key)) ....
    }
 
BR/Torsten

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux