New Lines to Paragraphs PHP Function

This is a great php function, written by Matthew Mullenweg, that will format text that has been pulled from a MySQL database so that it is displayed with HTML paragraph tags.

The function will replace new lines/carriage returns or even HTML line breaks with the paragraph tags, within the given string.

I have used this in a couple of different areas and it works great! One place is on the Hip Hop Rappers Lyrics pages, plus any other page that has text pulled from the database. Great stuff! This goes in conjunction well with CSS for formating the paragraphs to my likings. You can also specify a CSS class to use with the paragraph.

New Lines to Paragraphs PHP Function

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>