Re: Recurs Directory Delete

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux