用特殊字符替换字符串

时间:2011-11-19 00:14:31

标签: php replace

我有这个字符串:image/fewe我想用其他东西替换,但我不确定我会怎么做,也许有任何帮助?

2 个答案:

答案 0 :(得分:0)

str_replace("replace_me", "replace_with", 'image/fewe');

preg_replace() // you'll need to look that up to match your regex with your needs.

不确定你还在寻找什么。

答案 1 :(得分:0)

$string = 'image/fewe';
$replaceItWith = 'another string';
$result = str_replace('image/fewe', $replaceItWith, $string);

如果要搜索字符串中的模式,请使用preg_replace()