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 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"; ?> 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
Archived
This topic is now archived and is closed to further replies.