标签: php replace str-replace backslash
我有以下字符串:
$text = 'Some slash\'s';
这是我的字符串替换:
$text = str_replace('\'','\\\'',$text);
我最终想要的是:
$text = 'Some slash\\\'s';
我认为我做错了。
答案 0 :(得分:1)
我不知道您为什么要这样做,但我认为以下内容应该有效:
$text = str_replace('\'', "\\\\\\'", $text);