php delete foldersteemCreated with Sketch.

in php •  7 years ago 

// delete file or folder

function delFile($fnm){
if(is_dir($fnm))
delTree($fnm);
else
unlink($fnm);
}
function delTree($dir){
$files = array_diff(scandir($dir), array('.', '..'));
foreach ($files as $f1) {
(is_dir("$dir/$f1")) ? delTree("$dir/$f1") : unlink("$dir/$f1");
}
return rmdir($dir);
}

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!