You are here: RE: [PHP] Delete all files in DIR every 20 days « PHP « IT news, forums, messages
RE: [PHP] Delete all files in DIR every 20 days

Posted by Torsten Rosenberger on 10/04/72 11:08

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация