note 70997 deleted from function.rmdir by aidan

From: Date: Wed, 15 Apr 2009 04:25:13 +0000
Subject: note 70997 deleted from function.rmdir by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153260@lists.php.net to get a copy of this message
Note Submitter: fkjaekel at yahoo dot com dot br ---- Using SPL: <?php function recursiveRemoveDirectory($path) { $dir = new RecursiveDirectoryIterator($path); //Remove all files foreach(new RecursiveIteratorIterator($dir) as $file) { unlink($file); } //Remove all subdirectories foreach($dir as $subDir) { //If a subdirectory can't be removed, it's because it has subdirectories, so recursiveRemoveDirectory is called again passing the subdirectory as path if(!@rmdir($subDir)) //@ suppress the warning message { recursiveRemoveDirectory($subDir); } } //Remove main directory rmdir($path); } ?>

« previous php.notes (#153260) next »