I've used this function in a filemanager that I was working on, but never finished. Feel free to modify it to your liking.
PHP Code:
$home = "/home/www/mysite/"; //the path to your folder
remove_directory('testing'); /* call the function with the desired folder you wish to delete */
function remove_directory($fold) {
global $home;
if(substr($fold, -1, 1) == "/"){
$fold = substr($fold, 0, strlen($fold) - 1);
}
if ($open = opendir($home.$fold)) {
while (false !== ($item = readdir($open))) {
if ($item != "." && $item != "..") {
if (is_dir($home."$fold/$item")) { remove_directory("$fold/$item"); }
else { unlink($home."$fold/$item"); }
}
}
closedir($open);
rmdir($home.$fold);
}
}
Enjoy!
Bookmarks