简体   繁体   English

使用PHP在包含特定字符串的目录中搜索文件列表

[英]Use PHP to search a list of files within directorys that contain a certain string

I am trying to get PHP to search a list of files that are contained within a directory for a certain string. 我试图让PHP搜索目录中包含的某个字符串的文件列表。

For example PHP would search each of these text files for the string that you specify and then echo the names of the files out: 例如,PHP将在每个这些文本文件中搜索您指定的字符串,然后回显文件名:
XXXX/test.txt XXXX / test.txt
XXXX1/test.txt XXXX1 / test.txt
XXXX3/test.txt XXXX3 / test.txt

Is there way that I would be able to go about doing this? 有什么办法可以做到这一点?

First, consult the manual: 首先,请查阅手册:

http://php.net/manual/en/ref.filesystem.php http://php.net/manual/zh/ref.filesystem.php

http://www.php.net/manual/en/ref.dir.php http://www.php.net/manual/zh/ref.dir.php

Then, if you are unsure how to perform some specific part of your problem, formulate a question about that, showing what you've tried so far and where it isn't working as expected. 然后,如果您不确定如何执行问题的某些特定部分,请就此问题提出一个问题,以显示到目前为止您已尝试过的内容以及未按预期进行的地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM