It is necessary to display files from a directory containing a certain word. I find files from the directory:

$filename = "/"; foreach (glob("*.php") as $filename) { echo "{$filename}<br/>"; } 

How to make only the files with the search word displayed?

  • 1. Read the file, 2. Look for the word in it, 3. If the word is found, output the file name. What is the exact stage of the problem? Where is your attempt to solve? - Dmitriy Simushev
  • Perhaps you wrote a duplicate question: ru.stackoverflow.com/questions/137985 / ... Specify exactly what you mean by "find a specific word"? Need to find exactly the word, or just a substring? Problem solving will be different. - RAMe0

1 answer 1

 $phrase='blablabla'; foreach (glob("*.php") as $filename) { if(strpos(file_get_contents($filename),$phrase) !== false) echo "{$filename}<br/>"; }