Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: BBcode
Forum PHP.pl > Forum > PHP
bne
Witam, używam takiego skryptu bbcode :

  1. <?php
  2.  
  3.  
  4.  
  5. function bbcodetohtml($text) {
  6. $text = strip_tags($text);
  7. $text = nl2br($text);
  8.  
  9. $text = str_replace("","<b>", $text);
  10. $text = str_replace("","</b>", $text);
  11. $text = str_replace("","<i>", $text);
  12. $text = str_replace("","</i>", $text);
  13. $text = str_replace("","<u>", $text);
  14. $text = str_replace("","</u>", $text);
  15. $text = str_replace("
    ","<center>", $text);
  16. $text = str_replace("
    ","</center>", $text);
  •  
  • $text = str_replace("[aragorn]","<img src=images/emot/arag.gif title=Aragorn>", $text);
  • $text = str_replace("[boromir]","<img src=images/emot/boro.gif title=Boromir>", $text);
  • $text = str_replace("[gandalf]","<img src=images/emot/gand.gif title=Gandalf>", $text);
  • $text = str_replace("[gimli]","<img src=images/emot/gim.gif title=Gimli>", $text);
  • $text = str_replace("[legolas]","<img src=images/emot/lego.gif title=Legolas>", $text);
  • $text = str_replace("[saruman]","<img src=images/emot/saru.gif title=Saruman>", $text);
  •  
  • return $text;
  • }
  •  
  •  
  • function htmltobbcode($text) {
  •  
  • $text = str_replace("<b>","", $text);
  • $text = str_replace("</b>","", $text);
  • $text = str_replace("<i>","", $text);
  • $text = str_replace("</i>","", $text);
  • $text = str_replace("<u>","", $text);
  • $text = str_replace("</u>","", $text);
  • $text = str_replace("<center>","
    ", $text);
  • $text = str_replace("</center>","
    ", $text);
  •  
  • $text = str_replace("<img src=images/emot/arag.gif title=Aragorn>","[aragorn]", $text);
  • $text = str_replace("<img src=images/emot/boro.gif title=Boromir>","[boromir]", $text);
  • $text = str_replace("<img src=images/emot/gand.gif title=Gandalf>","[gandalf]", $text);
  • $text = str_replace("<img src=images/emot/gim.gif title=Gimli>","[gimli]", $text);
  • $text = str_replace("<img src=images/emot/lego.gif title=Legolas>","[legolas]", $text);
  • $text = str_replace("<img src=images/emot/saru.gif title=Saruman>","[saruman]", $text);
  • $text = str_replace("[golum]","<img src=images/emot/golum.gif title=Golum>", $text);
  •  
  • $text = strip_tags($text);
  •  
  • return $text;
  • }
  • ?>




  • Czy mógłby mi powiedzieć ktoś jak w tej funkcji użyć wstawiania obrazków?

    Od razu uprzedzę, że nie chce korzystać z generatora bbcode dostępnego w internecie...
    jarrod
    Cytat(bne @ 31.10.2006, 17:53:55 ) *
    Czy mógłby mi powiedzieć ktoś jak w tej funkcji użyć wstawiania obrazków?
    Od razu uprzedzę, że nie chce korzystać z generatora bbcode dostępnego w internecie...

    Leniwy kolego jesteś... Wyszukiwarka sprawna - sprawdzałem...

    Można taki efekt otrzymać korzystając z wyrażeń regularnych:

    1. <?php
    2. $t = 'jakiś text przed  jakiś text pomiędzy  i text po';
    3. $text = preg_replace(
    4. '/([img])(.*?)([/img])/',
    5. '<img src="2" alt="img" />',
    6. $t
    7. );
    8. ?>
    To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
    Invision Power Board © 2001-2025 Invision Power Services, Inc.