houssam_ballout Posted November 20, 2011 Share Posted November 20, 2011 Hello, I need help with this, I need a code that removes double occurrences of \\ only, but not if followed \n. for example Hello\\n should display Hello\ + new line Hello\\\n should display Hello + new line Hello\\ should display Hello Hello\\x should display Hellox Quote Link to comment https://forums.phpfreaks.com/topic/251499-help-with-php-str-replace-code/ Share on other sites More sharing options...
QuickOldCar Posted November 20, 2011 Share Posted November 20, 2011 does this help? <?php $text = "Hello\\n Hello\\\n Hello\\ Hello\\x "; $new_text = str_replace(array("\n","\\n")," <br />",$text); $new_text = stripslashes($new_text); //$new_text = str_replace("<br />","\n",$new_text);//reason to be \n ? echo "$new_text"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/251499-help-with-php-str-replace-code/#findComment-1289842 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.