Home  >  Article  >  Backend Development  >  高手大哥,速来,解决思路

高手大哥,速来,解决思路

WBOY
WBOYOriginal
2016-06-13 13:44:04720browse

高手大哥,速来,急。。。
请问如何 用JS命令替换c:\\a.txt中的指定字符nihao为haha 并且保持为一个新的文件为c:\\b.txt

说明 c:\\a.txt里面有很多杂乱的代码,但是只有一处 nihao 字符

------解决方案--------------------

PHP code
$contents = file_get_contents("c:\\a.txt");
if(!$contents)
   exit("查查文件路径是否正确");
$new_contents = str_replace("nihao", "haha", $contents);
file_put_contents("c:\\b.txt", $new_contents); 
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn