note 101374 deleted from function.unlink by danbrown
| From: | danbrown@php.net | Date: | Mon, 13 Dec 2010 16:32:07 +0000 |
| Subject: | note 101374 deleted from function.unlink by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174881@lists.php.net to get a copy of this message | ||
Note Submitter: anthony dot boulmier dot cfpt at gmail dot com
----
This function is as short as possible but i think it could be improved
/*
BOULMIER ANTHONY
13.12.2010
name: killdir
Description :A recursive function is used to delete a directory with 0,* files or directories in
him.
@params : path of the directory
@return : nothing
*/
function killdir($path)
{
$tab_file = scandir($path,0);
for($i=2;$i<count($tab_file);$i++)
{
if(is_dir($path."/".$tab_file[$i]))
{
$newpath = $path."/".$tab_file[$i];
killdir($newpath);
}else unlink($path."/".$tab_file[$i]);
}
rmdir($path);
}