上代码
/**
* 递归删除文件夹下的所有文件
*
* @param [type] $strDirPath
* @return void
* @author 一颗大萝北 [email protected]
*/
function dgRmDir($strDirPath)
{
$arrDirList = scandir($strDirPath);
unset($arrDirList[0]);
unset($arrDirList[1]);
$arrDirList = array_values($arrDirList);
foreach ($arrDirList as $k => $item) {
if (is_file($strDirPath . “\\” . $item)) {
unlink($strDirPath . “\\” . $item);
} else {
dgRmDir($strDirPath . “\\” . $item);
}
}
rmdir($strDirPath);
}
声明:
本文采用
BY-NC-SA
协议进行授权,如无注明均为原创,转载请注明转自
一颗大萝北
本文地址: php 删除指定文件夹及文件夹下的所有文件/文件夹
本文地址: php 删除指定文件夹及文件夹下的所有文件/文件夹