简体   繁体   中英

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.

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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