Here is my code:
$ParagArray=array('\r\n\r\n','\n\r\n\r','\r\r','\n\n');
foreach ($ParagArray as $value){
$chunks=(mb_split($value,$text));
$text=implode ("(PARAG)",$chunks);
}
echo "Here is the modified 1 text:<br/>";
echo $text;
echo "<br/>";
$LineArray=array('\r\n','\n\r','\r','\n');
foreach ($LineArray as $value){
$chunks=(mb_split($value,$text));
$text=implode ("(LINE)",$chunks);
}
echo "Here is the modified 2 text:<br/>";
echo $text;
echo "<br/>";
What I try to do here is identify paragraphs as being 2-line jumps, and carriage returns as being 1-line jumps. I replace them respectively with (PARAG) and (LINE) tags.
My problem is that I end up with (PARAG)(LINE) when the text incorporates 3 line jumps, (PARAG)(PARAG) when the text incorporates 4-line jumps, etc.
Is there a way for me to modify my code to catch all the cases when there are 2 or more line jumps and replacing all the line jumps with a single (PARAG)?
You could use: