image

PHP nl2br

echo nl2br("foo isn't\n bar");
Output:

foo isn’t
bar

What good is this you say. Well if you are like me and use striptags() in your forms you need a way to insert the linebreaks back on the echo. This will do it :)

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.