Directly run the code:
The following example shows how to delete the html of a specified directory. If you want other files, you only need to change the html to the suffix you want to delete.
| The code is as follows: |
Copy code |
<? 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 ');
}
// Var_dump ($ mstdel );
// Var_dump (count ($ mstdel ));
$ I = 0;
Foreach ($ mstdel as $ val ){
Foreach ($ val as $ val2 ){
// Echo $ val2. "<Br> ";
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: shanmaowwwwroottiantangtvxyxh4cc/sheji/20312.html '));
?> |