使用 PHP 搜索目录中包含特定字符串的文件列表
我试图让 PHP 搜索目录中包含的文件列表中的某个字符串。
例如,PHP 将在每个文本文件中搜索您指定的字符串,然后回显文件名:
XXXX/test.txt
XXXX1/test.txt
XXXX3/test.txt
有什么办法可以做到这一点吗?
I am trying to get PHP to search a list of files that are contained within a directory for a certain string.
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:
XXXX/test.txt
XXXX1/test.txt
XXXX3/test.txt
Is there way that I would be able to go about doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,查阅手册:
http://php.net/manual/en/ref.filesystem .php
http://www.php.net/manual/en /ref.dir.php
然后,如果您不确定如何执行问题的某些特定部分,请提出一个有关该问题的问题,显示到目前为止您已尝试过的内容以及未按预期工作的地方。
First, consult the manual:
http://php.net/manual/en/ref.filesystem.php
http://www.php.net/manual/en/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.