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
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);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.