php删除同目录下所有txt文件解决方案

WBOY
Release: 2016-06-13 10:13:02
Original
889 people have browsed it

php删除同目录下所有txt文件
这个语句怎么写?

------解决方案--------------------
先遍历该文件夹,然后用pathinfo判断扩展名,然后unlink
------解决方案--------------------
foreach(glob('目录名/*.txt') as $f)
unlink($f);
------解决方案--------------------

PHP code
 $files=glob("*.txt"); foreach($files as $file)   unlink($file);<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code
$files=glob("*.txt"); foreach($files as $file)   if(is_file($file)### dir1/dir2/dir3.txt/     unlink($file);<br><font color="#e78608">------解决方案--------------------</font><br>当你了解php有一个函数:glob()之后,您就知道这个问题如何处理了。<br>glog()用法详解:http://www.e2003.net/html/article-2984.html<br><div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!