Best way to find two newlines
Posted: Thu Apr 16, 2009 4:07 pm
What's the best way to determine if there are two or more newlines or just one in a string.
Example: I have these strings:
$String = "This is \n a string";
I want to replace the \n in this case with a <br />
$String = "This is \n\n a string";
I want to replace the \n\n in this case with a <hr />
or basically if there are more than one \n I want to replace all of them with <hr /> and if there is just one newline I just want it to be replaced with a <br />
Example: I have these strings:
$String = "This is \n a string";
I want to replace the \n in this case with a <br />
$String = "This is \n\n a string";
I want to replace the \n\n in this case with a <hr />
or basically if there are more than one \n I want to replace all of them with <hr /> and if there is just one newline I just want it to be replaced with a <br />