Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> bb code preg replace
dragoner
post
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 28.05.2011

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


  1. $t= mysql_fetch_array(mysql_query("select * from phpbb_posts_text where post_id=".$_GET["post"]));
  2. $tekst=$t["post_text"];
  3.  
  4. function BBCode($tekst)
  5. {
  6. $tekst = nl2br($tekst);
  7. $tekst = htmlspecialchars($tekst);
  8.  
  9. $tekst = preg_replace("#\[b\](.*?)\[/b\]#si",'<b>\\1</b>',$tekst);
  10. $tekst = preg_replace("#\[i\](.*?)\[/i\]#si",'<i>\\1</i>',$tekst);
  11. $tekst = preg_replace("#\[u\](.*?)\[/u\]#si",'<u>\\1</u>',$tekst);
  12. $tekst = preg_replace("#\[s\](.*?)\[/s\]#si",'<s>\\1</s>',$tekst);
  13.  
  14. $tekst = preg_replace("#\[img\](.*?)\[/img\]#si",'<img src="\\1" alt="" />',$tekst);
  15. $tekst = preg_replace("#\[img=(.*?)\](.*?)\[/img\]#si",'<img src="\\1" alt="\\2" />',$tekst);
  16.  
  17. $tekst = preg_replace("#\[color=(.*?)\](.*?)\[/color\]#si",'<font color="\\1">\\2</font>',$tekst);
  18.  
  19. $tekst = preg_replace("#\[url\](http.*?)\[/url\]#si", "<A HREF=\"\\1\">\\1</A>", $tekst);
  20. $tekst = preg_replace("#\[url=(http.*?)\](.*?)\[/url\]#si", "<A HREF=\"\\1\" TARGET=\"_blank\">\\2</A>", $tekst);
  21. $tekst = preg_replace("#\[url\](.*?)\[/url\]#si", "<A HREF=\"http://\\1\">\\1</A>", $tekst);
  22. $tekst = preg_replace("#\[url=(.*?)\](.*?)\[/url\]#si", "<A HREF=\"http://\\1\">\\2</A>", $tekst);
  23.  
  24. $tekst = preg_replace("#\[quote\](.*?)\[/quote\]#si",'<blockquote class="cytat">\\1</blockquote>',$tekst);
  25. $tekst = preg_replace("#\[quote=(.*?)\](.*?)\[/quote\]#si",'<p><cite>\\1</cite> napisał:</p><blockquote>\\2</blockquote>',$tekst);
  26.  
  27. $tekst = preg_replace("#\[code\](.*?)\[/code\]#si",'<pre>\\1</pre>',$tekst);
  28.  
  29.  
  30.  
  31. return($tekst);
  32. }
  33.  
  34.  
  35. echo BBCode();
  36.  
  37.  
  38.  
  39. mysql_close($link);
  40.  
  41. ?>

czemu nie dziala? haha.gif

Ten post edytował dragoner 28.05.2011, 15:01:14
Go to the top of the page
+Quote Post

Posty w temacie


Closed TopicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 22:33