查找并替换多个文件

Dav*_*vid 7 php

好吧,最好的解决方案是在php中搜索一堆文件内容以获取某个字符串并将其替换为其他内容.

完全像记事本++如何做到但显然我不需要接口.

Byr*_*ock 23

foreach (glob("path/to/files/*.txt") as $filename)
{
    $file = file_get_contents($filename);
    file_put_contents($filename, preg_replace("/regexhere/","replacement",$file));
}
Run Code Online (Sandbox Code Playgroud)