Here's my stack-based pseudo-recursive rmdir. It borrows
heavily from andy at mentalist's.
<?php
function rmdir_r($path) {
if (!is_dir($path)) {return false;}
$stack = Array($path);
while ($dir = array_pop($stack)) {
if ( rmdir($dir)) {continue;}
$stack[] = $dir;
$dh = opendir($dir);
while (($child = readdir($dh)) !== false) {
if ($child[0] == '.') {continue;}
$child = $dir . DIRECTORY_SEPARATOR . $child;
if (is_dir($child)) {$stack[] = $child;}
else {unlink($child);}
}
}
return true;
}
?>
----
Server IP: 209.41.74.194
Probable Submitter: 64.105.153.106
----
Manual Page -- http:
//www.php.net/manual/en/function.rmdir.php
Edit -- https://master
.php.net/note/edit/77476
Del: integrated -- h
ttps://master.php.net/note/delete/77476/integrated
Del: useless -- http
s://master.php.net/note/delete/77476/useless
Del: bad code -- htt
ps://master.php.net/note/delete/77476/bad+code
Del: spam -- https:/
/master.php.net/note/delete/77476/spam
Del: non-english --
https://master.php.net/note/delete/77476/non-english
Del: in docs -- http
s://master.php.net/note/delete/77476/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/77476
Reject -- https://mast
er.php.net/note/reject/77476
Search -- https://
master.php.net/manage/user-notes.php
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|