note 78368 added to function.rmdir
| From: | lior at realdice dot com | Date: | Mon, 08 Oct 2007 16:55:23 +0000 |
| Subject: | note 78368 added to function.rmdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131237@lists.php.net to get a copy of this message | ||
This will delete a directory and its' contents.
Set DIRECTORY_SEPARATOR to whatever fits the target OS.
function deltree($path) {
if (is_dir($path)) {
$entries = scandir($path);
foreach ($entries as $entry) {
if ($entry != '.' && $entry != '..') {
deltree($path.DIRECTORY_SEPARATOR.$entry);
}
}
rmdir($path);
} else {
unlink($path);
}
}
----
Server IP: 208.69.120.35
Probable Submitter: 87.70.70.12
----
Manual Page -- http://www.php.net/manual/en/function.rmdir.php
Edit -- https://master.php.net/note/edit/78368
Del: integrated -- https://master.php.net/note/delete/78368/integrated
Del: useless -- https://master.php.net/note/delete/78368/useless
Del: bad code -- https://master.php.net/note/delete/78368/bad+code
Del: spam -- https://master.php.net/note/delete/78368/spam
Del: non-english -- https://master.php.net/note/delete/78368/non-english
Del: in docs -- https://master.php.net/note/delete/78368/in+docs
Del: other reasons-- https://master.php.net/note/delete/78368
Reject -- https://master.php.net/note/reject/78368
Search -- https://master.php.net/manage/user-notes.php