这是我的文件 然后文件中 我把hello world替换成了你好,把this is test 替换成了测试。
但是每次只替换最下面的内容,hello world必须删除最下面的命令然后执行才可以替换,
求助一下怎么才可以替换~<?php
$str=file_get_contents("f:soft\\test.txt");//打开文件
$mode="/he.*rld/";
$arr=preg_replace($mode,'你好',$str);
$mode1="/th.*test/i";
$arc=preg_replace($mode1,'测试',$str);
file_put_contents("f:soft\\test.txt",$arr);//把替换的内容写到.txt文件中
file_put_contents("f:soft\\test.txt",$arc);
?>
但是每次只替换最下面的内容,hello world必须删除最下面的命令然后执行才可以替换,
求助一下怎么才可以替换~<?php
$str=file_get_contents("f:soft\\test.txt");//打开文件
$mode="/he.*rld/";
$arr=preg_replace($mode,'你好',$str);
$mode1="/th.*test/i";
$arc=preg_replace($mode1,'测试',$str);
file_put_contents("f:soft\\test.txt",$arr);//把替换的内容写到.txt文件中
file_put_contents("f:soft\\test.txt",$arc);
?>
解决方案 »
- 一个正则表达式的问题,数字的个数写1就可以匹配上,写比1大的就匹配不上了。
- windows xp2下 apache_2.2.6+php-5.2.6+MySQL-5.0.45+phpMyAdmin-2.11.6+ZendOptimizer-3.3.0a 配置
- (老问重发)用javascript如何解码urlEncode编码过的中文?(一定要JAVASCRIPT语言)
- php中用header()传HTTP头到客户端,让客户端下载文件,IE中没有问题,firefox中却不行,求教各位
- 有人可以在mysql中输入“烜、昉、燊、玥”四个字吗?
- 请教一个PHP调用问题
- apache的虚拟主机问题,我这么配怎么不好使呢?:(
- 我想知道html中做个连接,gif图片显示后,右下角有个小横线,怎么去掉?
- 1○○分 求:计算在线用户 的程序!
- php做网站的wap版,如何实现图片文件的上传
- php在win下模拟的多线程问题
- 谁给点PHP源码
$str=file_get_contents("f:soft\\test.txt");//打开文件
$mode="/he.*rld/";
$arr=preg_replace($mode,'你好',$str);
$mode1="/th.*test/i";
$arc=preg_replace($mode1,'测试',$arr);
file_put_contents("f:soft\\test.txt",$arc);