I'm trying to remove line breaks from a user-inputted string and trying to do this using ereg_replace and a regular expression but struggling, hope someone can help!
I would like to make all triple or more consecutive occurences of \n, \n\n. So if the pattern found \n\n\n or \n\n\n\n and so on it would replace with \n\n.
My plan is then to split() the string into an array using the double linebreak and then output each array member enclosed in <p> elements. So what i would end up with is a neat list of paragraphs.
Here is the code I have so far:
Expand|Select|Wrap|Line Numbers
- ereg_replace("\n{3,}","\n\n",$inputText);
Thanks in advance,
Chromis