2011-02-17 48 views
0

我有,例如,这个字符串$string='Hello World, hello world'; 我有大写或小写的参数,我需要更换所有的平等字<stong>word</strong>替换字符串的话十个分量原始字符串的小写和大写字符

如果我试试这个: $newstring=str_ireplace('world','<strong>world<s/trong>',$string);

结果是世界,你好,你好世界(小写字母W的第一个字)是要posssible替换字符串保持原始字符串的小写和upercases?

谢谢,对不起,我的英语

+0

preg_replace希望之一 – 2011-02-17 11:47:36

回答

4

这是很容易与preg_replace完成。

$string = preg_replace('/world/i', '<strong>$0</strong>', $string); 
+0

哇完美,很多谢谢,正是我所想 – David 2011-02-17 14:35:08

相关问题