我想用特殊条件替换某些字符。 像替换字符串中的特殊字符
所以如果
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/)**。 –