Page 2 of 2

Re: how to replace \" with just "

Posted: Thu Apr 07, 2011 11:29 am
by greyhoundcode
califdon wrote:But how are you getting this? Are you receiving this in a POST variable from a form? Are you scraping this from another forum? There are a lot of issues here, and you're not explaining where this data comes from
stevestark5000 wrote:i am getting an error with the code. are you sure the double quotes is ok?

Code: Select all

preg_replace('\"', '"', $_POST[''])
Perhaps if you clarify things a bit and explain the scenario more fully - just like Califdon suggested - you would get clearer help.

Some built-in functions for you to consider include stripslashes() and htmlentities().

Re: how to replace \" with just "

Posted: Thu Apr 07, 2011 4:14 pm
by stevestark5000
i am getting my variable from $_POST. after the preview button is pressed i get the post variable there.

stripslashes wont work for me because i need to users slashes to remain where there are

Code: Select all

<?php
$str = "Is your name O\'reilly?";

// Outputs: Is your name O'reilly?
echo stripslashes($str);
?>

here is the error when using preg_replace
Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash in

Re: how to replace \" with just "

Posted: Thu Apr 07, 2011 5:44 pm
by stevestark5000
solved. i did $content = str_replace('\"', '"', $content); on a new line

Re: [SOLVED] how to replace \" with just "

Posted: Thu Apr 07, 2011 9:19 pm
by fugix
glad it worked for you.