使用php在文本文件中搜索短语/单词

use*_*est 5 php directory search full-text-search

如何扫描目录中的特定文本行并使用php列出所有匹配的文件?

谢谢.

ani*_*son 7

我实际上几天前为此写了一个函数...

这是扫描每个文件的基本功能......

foreach (glob("<directory>/*.txt") as $search) {
    $contents = file_get_contents($search);
    if (!strpos($contents, "text")) continue;
    $matches[] = $search;
}
Run Code Online (Sandbox Code Playgroud)

不是最先进的方式,我的功能更长,但它也使用我的各种其他类的所有功能,这基本上是它的功能.