At 11:55 AM -0700 7/14/06, Mark Steudel wrote:
>I was hoping someone could give me a hand, I'm trying to create a delete
>folders function that recursively deletes folders and files from a given
>directory.
This works for me:
<?php
$path = "tmp";
if ($handle = opendir($path))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$file_array[] = $file;
}
}
closedir($handle);
}
if (isset($file_array))
{
echo ("<br/>---- before delete");
echo ("<pre>");
print_r($file_array);
echo("</pre>");
foreach ($file_array as $value)
{
unlink("$path/$value");
}
}
else
{
echo ("<br/>---- nothing to delete");
}
?>
hth's
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php