note 87385 deleted from function.rmdir by danbrown
| From: | danbrown@php.net | Date: | Wed, 11 Mar 2009 14:05:55 +0000 |
| Subject: | note 87385 deleted from function.rmdir by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-151733@lists.php.net to get a copy of this message | ||
Note Submitter: elprez at free dot fr
----
A simple recursive function freely inspired from hoffmeister
<?php
function rmdir_recurse($path)
{
$path= rtrim($path, '/').'/';
$handle = opendir($path);
for (;false !== ($file = readdir($handle));)
if($file != "." and $file != ".." )
{
$fullpath= $path.$file;
if( is_dir($fullpath) )
{
rmdir_recurse($fullpath);
rmdir($fullpath);
}
else
unlink($fullpath);
}
closedir($handle);
}
?>