tags:

views:

21

answers:

2

Hi All,

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 "?

+3  A: 

You can try using stripslashes

codaddict
+2  A: 

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);
KennyTM