How to avoid problems while removing not empty folders?
by barkkathulla[ Edit ] 2013-08-30 19:36:45
Easy way to remove content folders or we can use this for deleteing empty folders and files....
The script is given below:
$folderpath="your directory path";
if (is_dir($folderpath)) {
$objects = scandir($folderpath);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($folderpath."/".$object) == "dir") rmdir($folderpath."/".$object);
else unlink($folderpath."/".$object);
}
}
reset($objects);
rmdir($folderpath);
}
Guna
Where you checking the directory is empty or not?
0
0
Add Reply