RE: [PHP] Delete all files in DIR every 20 days

From: Date: Mon, 14 Feb 2005 17:09:32 +0000
Subject: RE: [PHP] Delete all files in DIR every 20 days
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-208656@lists.php.net to get a copy of this message
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

« previous php.general (#208656) next »