[SOLVED] how to replace \" with just "

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: how to replace \" with just "

Post 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().
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

Re: how to replace \" with just "

Post 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
stevestark5000
Forum Commoner
Posts: 61
Joined: Thu Jan 27, 2011 12:08 am

Re: how to replace \" with just "

Post by stevestark5000 »

solved. i did $content = str_replace('\"', '"', $content); on a new line
Last edited by stevestark5000 on Thu Apr 07, 2011 10:40 pm, edited 1 time in total.
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

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

Post by fugix »

glad it worked for you.
Post Reply