Textarea input - how to deal with paragraphs and headings?

DoctorUltra

New Member
I currently use the following expression which I use to put paragraph tags around textarea input before storing it in a MySQL database.\[code\]$inputText = str_replace('<p></p>', '', '<p>' . preg_replace('#([\r\n]\s*?[\r\n]){2,}#', '</p>$0<p>', $inputText) . '</p>');\[/code\]This works well and good, except when I wish to use header tags. These are then surrounded by unwanted paragraph tags:\[code\]<p><h3>Test Header</h3></p>\[/code\]While this displays as expected, it is not great from a validation point of view.Can anyone suggest an improved expression and/or method to catch headers tags and only apply the paragraph tags to actual paragraphs? Or, an expression which I can apply to my input prior to the expression I'm currently using to produce the same desired effect.As a side note, I would like to be able to enter stand-alone hyperlink 'a' tags and still have them surrounded with paragraph tags as before.I have considered that it may just be easier to manually edit the details after they are entered into the database to remove the unwanted paragraph tags.
 
Back
Top