note 65917 deleted from function.rmdir by bjori
| From: | bjori@php.net | Date: | Wed, 10 May 2006 07:22:02 +0000 |
| Subject: | note 65917 deleted from function.rmdir by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-111020@lists.php.net to get a copy of this message | ||
Note Submitter: nick at customdesigns dot ca
----
I don't understand what the fuss below is about with creating a recursive rmdir function. Mine
is simple:
public static function RecursiveRMDir($path)
{
if(!is_dir($path))
{
trigger_error("<p>{$path} is not a directory!</p>", E_USER_ERROR);
}
$dir = dir($path);
while (false !== ($dir_entry = $dir->read()))
{
if(($dir_entry != ".") && ($dir_entry != ".."))
{
if(!is_dir("{$path}/{$dir_entry}"))
{
unlink("{$path}/{$dir_entry}");
}
else
{
Utilities::RecursiveRMDir("{$path}/{$dir_entry}");
}
}
}
rmdir($path);
}