Reputation: 6755
So I'm using Wordpress' database object to store things into tables. One of the drawbacks (or advantages, depending on how you look at it) is that it escapes the single and double quote characters so that:
' --> \'
" ---> \"
What regex can I apply to the output to replace all \' with ' and \" with "?
Upvotes: 0
Views: 40
Reputation: 523184
Use stripslashes
$newstr = stripslashes($str);
Note that stripslashes
will replace \\
by \
as well. If you don't want this, you could use str_replace
:
$newstr = str_replace(array('\\\'', '\\"'), array('\'', '"'), $str);
Upvotes: 2