php – 在多个文件中查找和替换
发布时间:2020-12-13 18:25:10 所属栏目:PHP教程 来源:网络整理
导读:好吧,最好的解决方案是在php中搜索一堆文件内容以获取某个字符串并将其替换为其他内容. 完全像记事本如何做,但显然我不需要接口. foreach (glob("path/to/files/*.txt") as $filename){ $file = file_get_contents($filename); file_put_contents($filename,
好吧,最好的解决方案是在php中搜索一堆文件内容以获取某个字符串并将其替换为其他内容.
完全像记事本如何做,但显然我不需要接口. foreach (glob("path/to/files/*.txt") as $filename) { $file = file_get_contents($filename); file_put_contents($filename,preg_replace("/regexhere/","replacement",$file)); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |