I'm kinda new to PHP's pattern matching function.
here is the working code:
What I want to do is something like thisPHP Code:$two="/\r\n\r\n/"
$summary=htmlentities($summary);
$summary=preg_replace("$two","Ý",$summary);
$summary=preg_replace("/Ý+/","<br><br>",$summary);
$summary=html_entity_decode($summary);
$summary=preg_replace("/<p>/","",$summary);
where the '+' is applied to \r\n\r\n and not just \n. In the first example I converted it to a weird character like Ý and applied the '+' to that instead and then reconverted the chained occurances of Ý to a single occurance of <br><br>.PHP Code:$summary=preg_replace("/\r\n\r\n+/","<br><br>",$summary);
For visitors who are a bit lost here and is a short explanation of some of the terms:
\r = a carriage return. A carriage return is what happens when you want to go down a line and to the left using an old fashioned type writer.
\n = newline. it goes directly down a line.
When typing a web document the enter button creates two non-printing characters /r/n that both occur together for some reason.
preg_replace replaces all occurances of a term from a string.
html_entity_decode and htmlentities are just ways to convert a web file into a different format like making < appear as < instead.



Reply With Quote


Bookmarks