note 108460 added to function.rmdir
| From: | egiatgmxdotch | Date: | Fri, 27 Apr 2012 16:46:58 +0000 |
| Subject: | note 108460 added to function.rmdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-187383@lists.php.net to get a copy of this message | ||
The previous post doesn't match dot files and follows symlinks - which is probably not what you
really want!
This version should do the trick in all cases:
<?php
function rrmdir($dir) {
$fp = opendir($dir);
if ( $fp ) {
while ( $f = readdir($fp) ) {
$file = $dir . "/" . $f;
if ( $f == "." || $f == ".." ) {
continue;
}
else if ( is_dir($file) ) {
rrmdir($file);
}
else {
unlink($file);
}
}
closedir($fp);
rmdir($dir);
}
}
?>
PS: Sorry, I blundered on the previous post (which actually should be deleted) - please ignore it
:-)
----
Server IP: 194.153.94.10
Probable Submitter: 91.137.38.44
----
Manual Page -- http://www.php.net/manual/en/function.rmdir.php
Edit -- https://master.php.net/note/edit/108460
Del: integrated -- https://master.php.net/note/delete/108460/integrated
Del: useless -- https://master.php.net/note/delete/108460/useless
Del: bad code -- https://master.php.net/note/delete/108460/bad+code
Del: spam -- https://master.php.net/note/delete/108460/spam
Del: non-english -- https://master.php.net/note/delete/108460/non-english
Del: in docs -- https://master.php.net/note/delete/108460/in+docs
Del: other reasons-- https://master.php.net/note/delete/108460
Reject -- https://master.php.net/note/reject/108460
Search -- https://master.php.net/manage/user-notes.php