【发布时间】:2012-01-29 18:16:33
【问题描述】:
我想用"hi" from "this is nice place. <br> hello world.<br>thanks and regards" 替换"hello world." 和之后的任何字符preg_replace()
代码是这样的
$arr1 = array('/hello world./');
$arr2 = array('hi');
$str = "this is nice place. <br> hello world.<br>thanks and regards.";
echo preg_replace($arr1, $arr2, $str);
但是有了这个,我不仅能够替换“hello world”。从 $str。但我希望正则表达式替换“hello world”之后的所有字符。还。
【问题讨论】:
-
那么...问题是什么?您的代码(有点)有效。
-
但是有了这个,我不仅能够替换“hello world”。从 $str。但我希望正则表达式替换“hello world”之后的所有字符。也。