Home > php教程 > PHP源码 > php 一句话删除目录下所有文件

php 一句话删除目录下所有文件

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-08 17:21:18
Original
1069 people have browsed it

一句话删除目录下所有文件是用到了三个函数,分别为 glob unlink array_map了,下面我们一起来看看。

<script>ec(2);</script>

例子

 代码如下 复制代码

array_map('unlink',glob('*'));

就这一句可以删除所以目录下的文件了,我们也可以指定目录,如

 代码如下 复制代码

array_map('unlink',glob('aaa/*'));

就是aa目录下所有文件了,下面讲一下这三个函数

glob() 函数返回匹配指定模式的文件名或目录
unlink()函数删除文件
array_map() 函数返回用户自定义函数作用后的数组。回调函数接受的参数数目应该和传递给 array_map() 函数的数组数目一致

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
How to create an array within an array?
From 1970-01-01 08:00:00
0
0
0
php array
From 1970-01-01 08:00:00
0
0
0
Array to array
From 1970-01-01 08:00:00
0
0
0
php array rotation
From 1970-01-01 08:00:00
0
0
0
array
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template