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]
|