Copy and paste code for : How to delete folder with files in php? is written bellow:
<?php//START- delete FOLDER-php delete function that deals with directories recursively
function deleteDir($folder_path) {
//Get a list of file paths using the glob function.
$fileList = glob($folder_path."/*");
//Loop through the array that glob returned.
foreach($fileList as $filename){
//Simply delete them one by one
unlink($filename);
}
rmdir($folder_path);//finally remove folder which is empty after above process
}
//END- delete FOLDER-php delete function that deals with directories recursively
?>
Discussion (0)
No approved comments yet. Start a thoughtful discussion.
Sign in to comment.