refiking Posted November 22, 2009 Share Posted November 22, 2009 I am trying to remove all of the backslashes from a variable, but it's just not working. here is what I have: $new = str_replace('\', '', $original); echo $new; Quote Link to comment https://forums.phpfreaks.com/topic/182527-help-with-str_replace/ Share on other sites More sharing options...
smerny Posted November 22, 2009 Share Posted November 22, 2009 try putting '\\' Quote Link to comment https://forums.phpfreaks.com/topic/182527-help-with-str_replace/#findComment-963391 Share on other sites More sharing options...
salathe Posted November 22, 2009 Share Posted November 22, 2009 Backslash is a special character in PHP strings, see http://php.net/types.string#language.types.string.syntax.single In your case, you would need: $new = str_replace('\\', '', $original); echo $new; Quote Link to comment https://forums.phpfreaks.com/topic/182527-help-with-str_replace/#findComment-963392 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.