note 104231 deleted from function.rmdir by danbrown
| From: | danbrown@php.net | Date: | Thu, 02 Jun 2011 17:57:58 +0000 |
| Subject: | note 104231 deleted from function.rmdir by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-180203@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
I replaced the static slash (/) for DIRECTORY_SEPARATOR system constant.
Now rrmdir works in Windows platforms
<?php
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir.DIRECTORY_SEPARATOR.$object) == "dir")
rrmdir($dir.DIRECTORY_SEPARATOR.$object); else unlink($dir.DIRECTORY_SEPARATOR.$object);
}
}
reset($objects);
rmdir($dir);
}
}
?>