note 70377 modified in function.rmdir by bobby
| From: | bobby@php.net | Date: | Thu, 19 Oct 2006 14:54:35 +0000 |
| Subject: | note 70377 modified in function.rmdir by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-118768@lists.php.net to get a copy of this message | ||
@null at php5 dot pl:
[EDITOR NOTE: Original User Note Removed]
What if their is a subdir in $path? Yeah recursion is the best solution to do it. Nice idea to it
with glob();
<?php
functio removeDir($path)
{
$path.="*";
foreach(glob($path) as $file)
{
if( is_file($file) === true ) {
unlink($file);
} elseif( is_dir($file) === true ) {
removeDir($file);
}
}
}
}
?>
--was--
@null at php5 dot pl:
What if their is a subdir in $path? Yeah recursion is the best solution to do it. Nice idea to it
with glob();
<?php
functio removeDir($path)
{
$path.="*";
foreach(glob($path) as $file)
{
if( is_file($file) === true ) {
unlink($file);
} elseif( is_dir($file) === true ) {
removeDir($file);
}
}
}
}
?>
http://php.net/manual/en/function.rmdir.php