I'm hoping that someone can help me out with a regular expression pattern that I need, to use in a preg_replace function.
I need to parse text being retrieved from a database, replacing line breaks with paragraph tags. The complicated bit is that the no matter how many line breaks there are following each other, or if there are spaces in between, only one set of paragraph tags must be produced:
Example:
No matter which of the previous strings are parsed I need the output to be:
So if my preg_replace were as follows:
Can anyone help me out with the $pattern?
TIA.
I need to parse text being retrieved from a database, replacing line breaks with paragraph tags. The complicated bit is that the no matter how many line breaks there are following each other, or if there are spaces in between, only one set of paragraph tags must be produced:
Example:
Code:
example1: $string = This is some text /n/n This is some more text.
example2: $string = This is some text /r /r /r This is some more text.
example3: $string = This is some text /n/n/n/n/n/n This is some more text.
No matter which of the previous strings are parsed I need the output to be:
Code:
This is some text </p><p> This is some more text.
So if my preg_replace were as follows:
Code:
preg_replace($pattern,'</p><p>',$string)
Can anyone help me out with the $pattern?
TIA.