note 94540 added to function.rmdir
| From: | dragos dot rusu at ymail dot com | Date: | Wed, 11 Nov 2009 08:50:04 +0000 |
| Subject: | note 94540 added to function.rmdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162741@lists.php.net to get a copy of this message | ||
Seems glob function doesn't return the hidden files.
Here's a PHP5 function for deleting a directory tree recursively.
function deleteDirectoryTree($dirPath, $deleteAlsoDirPath = true)
{
$dir_iterator = new RecursiveDirectoryIterator($dirPath);
$iterator = new RecursiveIteratorIterator($dir_iterator,
RecursiveIteratorIterator::CHILD_FIRST);
foreach ($iterator as $file) {
if (is_dir($file) )
{
@rmdir($file);
}
else
{
@unlink($file);
}
}
if ($deleteAlsoDirPath === true && is_dir($dirPath))
{
return @rmdir( $dirPath );
}
}
----
Server IP: 69.147.83.197
Probable Submitter: 85.204.33.66
----
Manual Page -- http://www.php.net/manual/en/function.rmdir.php
Edit -- https://master.php.net/note/edit/94540
Del: integrated -- https://master.php.net/note/delete/94540/integrated
Del: useless -- https://master.php.net/note/delete/94540/useless
Del: bad code -- https://master.php.net/note/delete/94540/bad+code
Del: spam -- https://master.php.net/note/delete/94540/spam
Del: non-english -- https://master.php.net/note/delete/94540/non-english
Del: in docs -- https://master.php.net/note/delete/94540/in+docs
Del: other reasons-- https://master.php.net/note/delete/94540
Reject -- https://master.php.net/note/reject/94540
Search -- https://master.php.net/manage/user-notes.php