View Full Version : stripslashes .... thing. Removing \ from multiple chars

03-21-2010, 09:57 AM
So. If I type:
The quick brown fox was too freakin' lazy to jump over the lazy dog.
I get:
The quick brown fox was too freakin\' lazy to jump over the lazy dog.
(I know the new PHP stops this, but I can't upgrade)
So if I use the command to remove slashes I get rid of all slashes (which I don't want to do), so I tried str_replace

$str3 = array("\\"", "\\'", "\\\");
$str4 = array("", "", "");
$str = str_replace($str3,$str4,$_POST['str']);
But that obviously didn't work. So how would I replace \" or \' or \\ with nothing?

(in the php above, it removed my single quote thing. it looked like this without and spaces: \ \ ' )

03-21-2010, 12:21 PM

$str = get_magic_quotes_gpc()?stripslashes($_POST['str']):$_POST['str'];

03-21-2010, 12:27 PM
Or you could try to disable magic_quotes_gpc via .htaccess (provided your HTTP server is Apache). You could try to add the following like to .htaccess for it:

php_flag magic_quotes_gpc Off

Of course before doing any changes in .htaccess, make a backup copy of your original .htaccess somewhere.

03-22-2010, 03:36 AM
Thank you SKDevelopment. That worked like a charm.