Jump to content

unnecessary <br /> after signs: '', ""


AndyPSV

Recommended Posts

after '', "" the script does unnecessary <br /> (or rather: "\r\n"); when those signs aren't present, it works fine

how to remove the unnecessary new line marks, after those signs?

 

<?php

$text = 'It feels good to be in the zone and not so good to be out of it -- whether below or above your comfort level. Money -- or lack thereof -- is just one of many ways to get there.

\'\'
aaa
""

bb';

function trimBR($s,$wrap=0,$html=0) {
   if($html <> 0) $s = htmlspecialchars($s);
   $s = trim(nl2br(preg_replace('/(\r\n|\t|\n){2,}/',"\r\n",$s)));
   $s = str_replace('<br />',"\r\n",$s);
   if($wrap <> 0) $s = wordwrap($s,$wrap,"<br />",true);
   return $s;
}

echo nl2br(trimBR($text));
# echo nl2br($text);

?>

Link to comment
https://forums.phpfreaks.com/topic/249934-unnecessary-after-signs/
Share on other sites

  • 2 weeks later...

done, thanks

 

<?php

$text = 'It feels good to be in the zone and not so good to be out of it -- whether below or above your comfort level. Money -- or lack thereof -- is just one of many ways to get there.

\'\'
aaa
""

bb';

function trimBR($s,$wrap=0,$html=0) {
if($html <> 0) $s = htmlspecialchars($s);
$s = trim(preg_replace('/(\r\n|\t|\n){2,}/',"\r\n\r\n",$s));
if($wrap <> 0) $s = wordwrap($s,$wrap,"<br />",true);
return $s;
}

echo trimBR($text);
#echo nl2br($text);

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.