But this doesn't work. What I exactly try to do?
- 1 enter result in 1 <br>
- 2 enters result in 1 <p>
- 3 or more enters result in 1 <p>
I take it this is the statement of what you want it to do, not what the code does that "doesn't work"?
For starters, let's factor out the common parts and reduce it to a minimal statement:
- 2 or more enters results in 1 <p>
- 1 enter results in 1 <br>
Then it's just a matter of executing them in sequence:
$message = ereg_replace ('\n\n+', '<br>', $message);
$message = nl2br($message);
Note if you take care of the paragraph mark first, you can use nl2br() for the rest.
$message = ereg_replace (\"\\n\\n\\n%\", \"<p>\", $message);