note 94766 added to function.unlink
| From: | EddyVlad at osu1 dot php dot net | Date: | Tue, 24 Nov 2009 04:59:25 +0000 |
| Subject: | note 94766 added to function.unlink | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163216@lists.php.net to get a copy of this message | ||
The shortest recursive delete possible.
<?php
/**
* Delete a file or recursively delete a directory
*
* @param string $str Path to file or directory
*/
function recursiveDelete($str){
if(is_file($str)){
return @unlink($str);
}
elseif(is_dir($str)){
$scan = glob(rtrim($str,'/').'/*');
foreach($scan as $index=>$path){
recursiveDelete($path);
}
return @rmdir($str);
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 220.255.7.105 (proxied: 219.75.49.24)
----
Manual Page -- http://www.php.net/manual/en/function.unlink.php
Edit -- https://master.php.net/note/edit/94766
Del: integrated -- https://master.php.net/note/delete/94766/integrated
Del: useless -- https://master.php.net/note/delete/94766/useless
Del: bad code -- https://master.php.net/note/delete/94766/bad+code
Del: spam -- https://master.php.net/note/delete/94766/spam
Del: non-english -- https://master.php.net/note/delete/94766/non-english
Del: in docs -- https://master.php.net/note/delete/94766/in+docs
Del: other reasons-- https://master.php.net/note/delete/94766
Reject -- https://master.php.net/note/reject/94766
Search -- https://master.php.net/manage/user-notes.php