New Lines to Paragraphs PHP Function
May 25, 2005 CSS, MySQL, PHP, Web Development
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.
Leave a Reply