Shoutbox

Can't treat backslashes as text in PHP - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Can't treat backslashes as text in PHP (/showthread.php?tid=64286)

Can't treat backslashes as text in PHP by absorbation on 07-31-2006 at 04:47 PM

Simple really, but I am not the best syntax expert and I need the help nice and quick please.

code:
$media = str_replace('\', '', $media);
It is that simple. I can't treat backslashes as text in a string no matter what I try and do. I am trying to get rid of backslashes from a variable and this is the only simple way I can think of. So the syntax fix would help me a lot. Thanks a bunch of bananas :).
RE: Can't treat backslashes as text in PHP by alexp2_ad on 07-31-2006 at 04:51 PM

You have to use a double backslash, since backslash is an escape character used for stuff like new lines (\n), so just '\\' will do nicely.


RE: Can't treat backslashes as text in PHP by absorbation on 07-31-2006 at 04:53 PM

I already tried that, and it still produces the same result :P. I am a bit confused on what to do here, nothing seems to work.

Edit: Found the solution, another variable was messing with the $media one. I moved it up the page and now it works :).


RE: Can't treat backslashes as text in PHP by ayjay on 07-31-2006 at 10:58 PM

Just use stripslashes() :P