Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Łamanie lini
daniel1302
post
Post #1





Grupa: Zarejestrowani
Postów: 602
Pomógł: 30
Dołączył: 1.08.2007
Skąd: Nowy Sącz

Ostrzeżenie: (0%)
-----


Witam, mam problem, mianowicie nie łamie mi lini. Próbowałem tak
  1. $txt = nl2br($txt);
  2. $txt = str_replace('\\n', "<br />", $txt);
  3. $txt = preg_replace('/((.?)+)\n/', '$1<br /></p>', $txt);


i żaden sposób nie działa. Z góry dziękuje
Oto kod funkcji
  1. function textShow($txt)
  2. {
  3. $txt = preg_replace('/\[tex\]((.?)+)\[\/tex\]/', '<br />'.texTransform('$1').'<br />', $txt);
  4. $txt = preg_replace('/\[b\]((.?)+)\[\/b\]/', '<b>$1</b>', $txt);
  5. $txt = preg_replace('/\[i\]((.?)+)\[\/i\]/', '<i>$1</i>', $txt);
  6. $txt = preg_replace('/\[u\]((.?)+)\[\/u\]/', '<u>$1</u>', $txt);
  7. $txt = preg_replace('/\[p\]((.?)+)\[\/p\]/', '<p>$1</p>', $txt);
  8. return $txt;
  9. }
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
PiotrekM
post
Post #2





Grupa: Zarejestrowani
Postów: 130
Pomógł: 6
Dołączył: 20.12.2009

Ostrzeżenie: (0%)
-----


  1. function textShow($txt)
  2. {
  3. $txt = nl2br($txt);
  4. $txt = preg_replace('/\[tex\]((.?)+)\[\/tex\]/', '<br />'.texTransform('$1').'<br />', $txt);
  5. $txt = preg_replace('/\[b\]((.?)+)\[\/b\]/', '<b>$1</b>', $txt);
  6. $txt = preg_replace('/\[i\]((.?)+)\[\/i\]/', '<i>$1</i>', $txt);
  7. $txt = preg_replace('/\[u\]((.?)+)\[\/u\]/', '<u>$1</u>', $txt);
  8. $txt = preg_replace('/\[p\]((.?)+)\[\/p\]/', '<p>$1</p>', $txt);
  9. return $txt;
  10. }
Go to the top of the page
+Quote Post
DiH
post
Post #3





Grupa: Zarejestrowani
Postów: 251
Pomógł: 34
Dołączył: 7.01.2010

Ostrzeżenie: (0%)
-----


W swoje pole spróbuj wpisać:
  1. [b]a[/b]w[b]x[/b]b
Proponowałbym raczej:
  1. "#(.*?)\[b\](.*?[^\[\]])\[/b\](.*?)#i"


Co do łamania linii, to jak kolega wyżej napisał - samo nl2br wystarczy w zupełności. Przejście do nowej linii to najczęściej \r\n.


Ten post edytował DiH 21.02.2010, 18:27:33
Go to the top of the page
+Quote Post
daniel1302
post
Post #4





Grupa: Zarejestrowani
Postów: 602
Pomógł: 30
Dołączył: 1.08.2007
Skąd: Nowy Sącz

Ostrzeżenie: (0%)
-----


Mi właśnie nie działa to nl2br
Go to the top of the page
+Quote Post
maly_swd
post
Post #5





Grupa: Zarejestrowani
Postów: 744
Pomógł: 118
Dołączył: 14.02.2009
Skąd: poziome

Ostrzeżenie: (0%)
-----


$txt = str_replace("\n", "<br />", $txt);
lub
$txt = str_replace("\r", "<br />", $txt);


--------------------
śmieszne obrazki
Kryzys: Ser jem spleśniały, wino piję stare i samochód mam bez dachu..
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 20.08.2025 - 09:23