Home > Article > Backend Development > PHP function to delete directory_PHP tutorial
php function to delete directory
Example application to delete a file directory:
function scmulu($mlming)
{
$dkml = opendir($mlming);
readdir($dkml);
readdir($dkml);
while(($wj = readdir($dkml))!==false)
{
$wj = $mlming.DIRECTORY_SEPARATOR.$wj;
if(is_dir($wj))
{
scmulu($wj);
}else
{
if(unlink($wj))
{
echo "File$wj was deleted successfully
";
}else
{
echo "File$wjfailed to delete
";
}
}
}
closedir($dkml);
if(rmdir($mlming))
{
echo "Directory$mlming was deleted successfully
";
}else
{
echo "Directory$mlmingfailed to delete
";
}
}