Posted by juglesh on 09/13/05 21:03
deletes a file, or a folder and everything in it, whatever you put into
$dirname.
function rmdirr($dirname)
{
// Sanity check
if (!file_exists($dirname)) {
echo "no directory by that name";
return false;
}
// Simple delete for a file
if (is_file($dirname)) {
return unlink($dirname);
}
// Loop through the folder
$dir = dir($dirname);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Recurse
rmdirr("$dirname/$entry");
}// end while looping
// Clean up
$dir->close();
return rmdir($dirname);
}
Navigation:
[Reply to this message]
|