For the longest time, I’ve been outputting comments and using the function below in order to put in line breaks. It’s been working great.
echo str_replace(chr(13),"<br />",$com_text);
However, as of late, this code has not been working with new comments. It still functions with the older comments in the database. But anything new being submitted into the database is not being outputted correctly.
No code has changed, that I’m aware of. Any suggestions?
Try using
echo nl2br($com_text);Or this regex which looks for new lines: