最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php批量删除指定文件夹中指定后缀名文件
时间:2022-06-24 17:29:30 编辑:袖梨 来源:一聚教程网
直接上代码:
下面的例子我们是以删除指定目录的html为例子哦,如果你要其它文件我们只要把html改成你自己要删除的后缀名就可以了。
代码如下 | 复制代码 |
$lanmu = array("action","tiyu","yizhi","sheji","gaoxiao","maoxian","qipai","celue","minjie","xiuxian","ertong","jingying","webgame"); foreach($lanmu as $v2){ $mstdel[] =glob(getcwd().DIRECTORY_SEPARATOR.$v2.DIRECTORY_SEPARATOR.'[1-9]*.html'); } //var_dump($mstdel); //var_dump(count($mstdel)); $i=0; foreach($mstdel as $val){ foreach($val as $val2){ //echo $val2." "; if(unlink($val2)) $i++; //$countval2[] = $val2; } } echo 'del success: '.$i; //echo count($countval2); //var_dump(glob(getcwd().DIRECTORY_SEPARATOR.'sheji'.DIRECTORY_SEPARATOR.'[1-9]*.html')); //var_dump(glob('./sheji/[1-9]*.html')); //var_dump(glob('./sheji/[^index]*.html')); //array_walk(glob(getcwd().'/sheji/[1-9]*.html'),'unlink'); //array_walk(glob('./sheji/[1-9]*.html'),'unlink'); //array_walk(glob(getcwd().DIRECTORY_SEPARATOR.'sheji'.DIRECTORY_SEPARATOR.'[1-9]*.html'),'unlink'); //var_dump(DIRECTORY_SEPARATOR); //var_dump(unlink('D:shanmaowwwwwwroottiantangtvxyxh4cc/sheji/20312.html')); ?> |
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22