note 108509 deleted from function.rmdir by danbrown
| From: | danbrown@php.net | Date: | Thu, 10 May 2012 16:51:29 +0000 |
| Subject: | note 108509 deleted from function.rmdir by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187603@lists.php.net to get a copy of this message | ||
Note Submitter: gianluca dot toso at gmail dot com
----
Thanks egi.
Just a note,
tha latest version follows symlinks, too.
This should work:
<?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) && !is_link($file)) {
rrmdir($file);
}
else {
unlink($file);
}
}
closedir($fp);
rmdir($dir);
}
}
?>