编辑字符串以在'之前添加\ [英] Editing a string to add a \ before a '

查看:62
本文介绍了编辑字符串以在'之前添加\的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个函数允许你在字符串中的''之前添加\。

这是在mysql数据库中存储文本所需要的,我想知道是否

是能够对任何'之前已经有一个

的人执行此操作的功能,这样我就可以继续编辑我的文本而不用所有这些\

积累。


亲切的问候


Marc

解决方案

monomaniac21写道:

是否有一个函数允许你在字符串中的''之前添加\。
这是存储文本所必需的在一个mysql数据库中,我想知道是否有
这个功能可以对任何'之前已经没有一个
的功能,这是我可以继续编辑我的文本而不是所有这些\\建立起来。

亲切的问候

Marc



请参阅addslashes()


-david-


您也可以尝试str_replace("''"," \\''",


string);


Is there a function that allows you to add a \ before a '' in a string.
This is needed to store text in a mysql db and i was wondering if there
is function which can do this to any '' which DO NOT already have one
before them, this is so i can keep editing my text without all these \
building up.

Kind regards

Marc

解决方案

monomaniac21 wrote:

Is there a function that allows you to add a \ before a '' in a string.
This is needed to store text in a mysql db and i was wondering if there
is function which can do this to any '' which DO NOT already have one
before them, this is so i can keep editing my text without all these \
building up.

Kind regards

Marc


see addslashes()

-david-


you also might want to try str_replace("''", "\\''",


string);


这篇关于编辑字符串以在'之前添加\的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆