2011-02-17 83 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

相關問題