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

发布于 2024-10-02 07:20:36 字数 163 浏览 0 评论 0原文

我试图让 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初吻给了烟 2024-10-09 07:20:36

首先,查阅手册:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文