最新下载
热门教程
- 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')); ?> |
相关文章
- 《绝区零》伊芙琳培养材料汇总 01-24
- 《无限暖暖》1.2春节兑换码一览 01-24
- 《网上国网》查询阶梯档位方法 01-24
- 《蛋仔派对》神游贺岁盲盒获取方法 01-24
- 《炉石传说》星际联动盗贼卡组玩法介绍 01-24
- 皮革珊瑚属于珊瑚中的 01-24