Revision: 10870
Updated Code
at January 16, 2009 08:11 by eden159
Updated Code
function removeDirs($path, $dirName, $delete = false) {
$dh = opendir($path);
while ($file = readdir($dh)) {
if($file != '.' && $file != '..') {
$fullpath = $path.'/'.$file;
if(!is_dir($fullpath)) {
if ( $delete ) {
@unlink($fullpath);
}
} else {
if ( $file == $dirName ) {
removeDirs($fullpath, $dirName, true);
@rmdir($fullpath);
} else {
removeDirs($fullpath, $dirName, $delete);
}
if ( $delete ) {
@rmdir($fullpath);
}
}
}
}
closedir($dh);
}
//example call
removeDirs('/var/www/temp', '.svn');
Revision: 10869
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 16, 2009 08:08 by eden159
Initial Code
function removeDirs($path, $dirName, $delete = false) {
$dh = opendir($path);
while ($file = readdir($dh)) {
if($file != '.' && $file != '..') {
$fullpath = $path.'/'.$file;
if(!is_dir($fullpath)) {
if ( $delete ) {
@unlink($fullpath);
}
} else {
if ( $file == $dirName ) {
removeDirs($fullpath, $dirName, true);
@rmdir($fullpath);
} else {
removeDirs($fullpath, $dirName, $delete);
}
if ( $delete ) {
@rmdir($fullpath);
}
}
}
}
closedir($dh);
}
Initial URL
Initial Description
Helpfull function to remove recursively specific folders.
Initial Title
Delete recursively specific folder (directories) with php
Initial Tags
php, directory
Initial Language
PHP