note 91485 deleted from function.rmdir by danbrown
| From: | danbrown@php.net | Date: | Fri, 12 Jun 2009 13:27:02 +0000 |
| Subject: | note 91485 deleted from function.rmdir by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156804@lists.php.net to get a copy of this message | ||
Note Submitter: tech at samboyer dot org
----
Shortest all-php recursive rmdir() implementation I've seen yet:
<?php
function rmdirr($path) {
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path),
RecursiveIteratorIterator::CHILD_FIRST) as $item) {
$item->isFile() ? unlink($item) : rmdir($item);
}
rmdir($path);
}
?>
yay SPL!