Warning: rmdir(..): Directory not empty
If you are attempting to delete a PHP file and that you get the error message “Warning: rmdir(..): Directory not empty”. This might mean that the directory is not empty. To be able to erase those files that are in the directory, there is a special PHP code that you can use in both the subfolders and the folders.
<?
rmdir_recursive function ($ dir)
(
/ / List the contents of the directory table
$ Dir_content = scandir ($ dir);
/ / Is it a directory?
If ($ dir_content! == FALSE) {
/ / For each directory entry
Foreach ($ dir_content as $ entry)
(
/ / Unix symbolic shortcuts, we go
If (! In_array ($ entry, array ('.','..'))){
/ / We find the path from the beginning
$ Entry = $ dir. '/'. $ entry;
/ / This entry is not an issue: it clears
If (! Is_dir ($ entry)) (
Unlink ($ entry);
)
/ / This entry is a folder, it again on this issue
Else (
Rmdir_recursive ($ entry);
}
}
}
}
/ / It has erased all entries in the folder, we can now erase
Rmdir ($ dir);
}
?>