Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] skrypt robi nieptrzebne <br /> po znakach "", ''
AndyPSV
post
Post #1





Grupa: Zarejestrowani
Postów: 393
Pomógł: 5
Dołączył: 6.02.2003
Skąd: The.Luciferian.Doctrine.p
df

Ostrzeżenie: (30%)
XX---


po "", czy '' - skrypt robi niepotrzebne <br /> (raczej: "\n\r"), podczas gdy tych znakow nie ma, wszystko dziala normalnie
jak to usunac?

  1. <?php
  2.  
  3. $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.
  4.  
  5. \'\'
  6. aaa
  7. ""
  8.  
  9. bb';
  10.  
  11. function trimBR($s,$wrap=0,$html=0) {
  12. if($html <> 0) $s = htmlspecialchars($s);
  13. $s = trim(nl2br(preg_replace('/(\r\n|\t|\n){2,}/',"\r\n",$s)));
  14. $s = str_replace('<br />',"\r\n",$s);
  15. if($wrap <> 0) $s = wordwrap($s,$wrap,"<br />",true);
  16. return $s;
  17. }
  18.  
  19. echo nl2br(trimBR($text));
  20. # echo nl2br($text);
  21.  
  22. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 13.10.2025 - 21:09