我想用特殊條件替換某些字符。 像替換字符串中的特殊字符
所以如果
a string contains _ is then replace it with .
a string contains __ is then replace it with _ (remove single _ multiple _)
a string starting with # then replace it with $
a string starting with ## then replace it with #
我已經試過
str_replace('_', '.', $string);
但替換所有_來。 ('4__69'給出4..69)
通常你必須嘗試這樣做會發生之前... –
所以我們在那裏做功課? – Troyer
在[所以]你應該嘗試**自己編寫代碼**。後** [做更多的研究](//meta.stackoverflow.com/questions/261592)**如果你有問題,你可以**發佈你已經嘗試**與清楚的解釋是什麼是'工作**並提供[** Minimal,Complete和Verifiable示例**](// stackoverflow.com/help/mcve)。我建議閱讀[問]一個好問題和[完美問題](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/)。另外,一定要參加[遊覽]並閱讀[this](// meta.stackoverflow.com/questions/347937/)**。 –