I have a form where users submit information and sometimes they put quotes:
example:
This is how "we" do it baby!
so how can I strip the double quotes in a string?
I've tried: $song_strip = str_replace("'","",$song_strip); but that errors out.
iBuddy wrote:I have a form where users submit information and sometimes they put quotes: example: This is how "we" do it baby! so how can I strip the double quotes in a string? I've tried: $song_strip = str_replace("'","",$song_strip); but that errors out.
U dont need to strip it out, u should use mysql_real_escape_string or htmlspecialchars or htmlenteties
Are you really trying to remove all double quotes? Not replace them with single quotes or escape them? If so...
$string = 'Hello "world"!'; $string = str_replace('"', '', $string); echo $string; // Hello world!
To replace both single and double quotes...
$song_strip = 'This is how "we" do it baby!'; $song_strip = str_replace(array('\'', '"'),"", $song_strip);