How to avoid problems while removing not empty folders?

by barkkathulla 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);
}
436
like
0
dislike
0
mail
flag

You must LOGIN to add comments
Guna

Where you checking the directory is empty or not?