Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] bbcode
Forum PHP.pl > Forum > Przedszkole
krzychu0808
witam chciałem zrobić mini bbcode w php i mam coś takiego:
  1. <?php
  2. $tekst = "aaaa <br/> [mp3=www.aaa.pl/xxx.mp3]xxxx[/mp3]";
  3. $tekst = htmlspecialchars($tekst);
  4. $tekst = preg_replace("#(.*?)#si", "<b>1</b>", $tekst);
  5. $tekst = preg_replace("#[mp3=(http://)?(.*?)](.*?)[/mp3]#si", "<a href=\"2\">3</a>", $tekst);
  6. echo $tekst;
  7. ?>


pogrubienie działa ale w linku adres mi daje w takiej postaci:
http://www.xxxx.eu/www.aaa.pl/xxx.mp3
zamiast
http://www.aaa.pl/xxx.mp3

proszę o pomoc
marcio
Dodaj target blank.
krzychu0808
zrobiłem
  1. <?php
  2. $tekst = "aaaa <br/> [mp3=www.aaa.pl/xxx.mp3]xxxx[/mp3]";
  3. $tekst = htmlspecialchars($tekst);
  4. $tekst = preg_replace("#(.*?)#si", "<b>1</b>", $tekst);
  5. $tekst = preg_replace("#[mp3=(http://)?(.*?)](.*?)[/mp3]#si", "<a href=\"2\" target=\"_blank\">3</a>", $tekst);
  6. echo $tekst;
  7. ?>

i nadal to samo
marcio
A dodaj http:// do linku ktory ma sie stworzyc
krzychu0808
  1. <?
  2. $tekst = "aaaa <br/> [mp3=http://www.aaa.pl/xxx.mp3]xxxx[/mp3]";
  3. $tekst = htmlspecialchars($tekst);
  4. $tekst = preg_replace("#(.*?)#si", "<b>1</b>", $tekst);
  5. $tekst = preg_replace("#[mp3=(http://)?(.*?)](.*?)[/mp3]#si", "<a href=\"2\" target=\"_blank\">3</a>", $tekst);
  6. echo $tekst;
  7. ?>


też lipka
marcio
  1. <?php
  2. $tekst = preg_replace("#[mp3=(http://)?(.*?)](.*?)[/mp3]#si", "<a href=\"2\" target=\"_blank\">3</a>", $tekst);
  3. ?>

Tu dodaj http://
krzychu0808
Wielkie dzięki działa
  1. <?php
  2. $tekst = "aaaa <br/> [mp3=http://www.aaa.pl/xxx.mp3]xxxx[/mp3]";
  3. $tekst = htmlspecialchars($tekst);
  4. $tekst = preg_replace("#(.*?)#si", "<b>1</b>", $tekst);
  5. $tekst = preg_replace("#[mp3=(http://)?(.*?)](.*?)[/mp3]#si", "<a href=\"http://2\" target=\"_blank\">3</a>", $tekst);
  6. echo $tekst;
  7. ?>
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.