Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Najlepszy parser bbcode ?
konrados
post
Post #1





Grupa: Zarejestrowani
Postów: 623
Pomógł: 79
Dołączył: 16.01.2008

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


Witam,

Próbuję coś znaleźć w googlu ale tego jest za dużo - chodzi mi o parser bbclode, byle by po prostu rozumiał takie rzeczy jak np.
CODE
[img]
, jaki byście proponowali?

w php.net ( http://pl2.php.net/bbcode ) znalazłem niby odpowiednie funkcje, ale coś trzeba instalować a ja nie mam takiej możliwości.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
AxZx
post
Post #2





Grupa: Zarejestrowani
Postów: 1 385
Pomógł: 55
Dołączył: 1.03.2005
Skąd: śląsk

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


  1. <?php
  2. public static function replace($tekst = '')
  3.    {
  4.        $tekst = preg_replace("#(.*?)#si",'<strong>$1</strong>',$tekst);
  5.        $tekst = preg_replace("#(.*?)#si",'<i>$1</i>',$tekst);
  6.        $tekst = preg_replace("#(.*?)#si",'<span class="podkreslony">$1</span>',$tekst);
  7.        $tekst = preg_replace("#[strong](.*?)[/strong]#si",'<strong>$1</strong>',$tekst);
  8.        $tekst = preg_replace("#[img](.*?)[/img]#si",'<img src="$1" alt="$1" title="$1" />',$tekst);
  9.        $tekst = preg_replace("#[img=(.*?)](.*?)[/img]#si",'<img src="$1" alt="$2" title="$2" />',$tekst);
  10.        $tekst = preg_replace("#[quote](.*?)[/quote]#si",'<span class="cytat">$1</span>',$tekst);
  11.        $tekst = preg_replace("#[code](.*?)[/code]#si",'<span class="kod">$1</span>',$tekst);
  12.        
  13.        return $tekst;
  14.    }
  15. ?>
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: 17.10.2025 - 19:20