这是一个比较实现的函数我们可以自定义要删除那些目录保存在一个数据中,然后我们根据数据进行遍历并且删除目录下指定文件了.
下面的例子我们是以删除指定目录的html为例子,如果你要其它文件我们只要把html改成你自己要删除的后缀名就可以了,代码如下:
- <?php
- $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');
- }
-
-
-
-
- $i=0;
- foreach($mstdel as $val){
- foreach($val as $val2){
-
- if(unlink($val2)) $i++;
-
- }
- }
- echo 'del success: '.$i;
-
-
-
-
-
-
-
-
-
-
-
- ?>
|