JSHINER Posted February 20, 2007 Share Posted February 20, 2007 Here is my code: $string = $z['description']; $string = wordwrap($string, 225, "|", 1); list($string) = explode('|', $string); echo'<br>'; echo str_replace("\n", '<br />', str_replace("\r\n", '<br />', str_replace("\n\n", '', str_replace("\r\n\r\n", '', htmlspecialchars($string))))); Works fine EXCEPT str_replace / htmspecialcharcters are not working. Do I have str_replace in the wrong spot? Should it be done before the wordwrap? Or before I define $z['description'] as the $string varialbe? Any help would be much appreciated. Link to comment https://forums.phpfreaks.com/topic/39341-solved-help-with-str_replace-should-be-a-quick-fix/ Share on other sites More sharing options...
craygo Posted February 20, 2007 Share Posted February 20, 2007 if all you are doing is changing \n or \r to <br> there is already a built in fuction for this nl2br($string); Ray Link to comment https://forums.phpfreaks.com/topic/39341-solved-help-with-str_replace-should-be-a-quick-fix/#findComment-189720 Share on other sites More sharing options...
JSHINER Posted February 20, 2007 Author Share Posted February 20, 2007 Still have the issue of - that's - display as - that\'s - Link to comment https://forums.phpfreaks.com/topic/39341-solved-help-with-str_replace-should-be-a-quick-fix/#findComment-189723 Share on other sites More sharing options...
Balmung-San Posted February 20, 2007 Share Posted February 20, 2007 stripslashes() Link to comment https://forums.phpfreaks.com/topic/39341-solved-help-with-str_replace-should-be-a-quick-fix/#findComment-189724 Share on other sites More sharing options...
JSHINER Posted February 20, 2007 Author Share Posted February 20, 2007 Great, that worked. Thank you ! Link to comment https://forums.phpfreaks.com/topic/39341-solved-help-with-str_replace-should-be-a-quick-fix/#findComment-189726 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.