note 43901 deleted from function.rmdir by tomsommer
| From: | tomsommer@php.net | Date: | Thu, 08 Jul 2004 07:25:55 +0000 |
| Subject: | note 43901 deleted from function.rmdir by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72866@lists.php.net to get a copy of this message | ||
Note Submitter: diogo@netmake.com.br
----
/* A simple form to remove folder(recursiv for its subdirs) or archives. You do not need worri about
"\" or "/" or with nothing, just give any dir. Tested and has easy language
*/
<?php
function delete($v_str_path)
{
if(strpos($v_str_path, "\\")!==false)
{
$v_str_path = str_replace("\\", "/", $v_str_path);
}
chmod($v_str_path, 0777);
if(is_dir($v_str_path))
{
if($v_str_path{strlen($v_str_path)-1}!="/")
{
$v_str_path .="/";
}
$handleDir = opendir($v_str_path);
while($filename = readdir($handleDir))
{
if($filename != "." && $filename != "..")
{
if(is_dir($v_str_path.$filename))
{
delete($v_str_path.$filename);
}else
{
unlink($v_str_path.$filename);
}
}
}
closedir($handleDir);
rmdir($v_str_path);
}else
{
unlink($v_str_path);
}
}
$dir = "D:/Inetpub/wwwroot/teste";
delete($dir);
?>