Autor | Zpráva | ||
---|---|---|---|
JAAkub Profil |
#1 · Zasláno: 17. 1. 2010, 07:44:22 · Upravil/a: JAAkub
Nazdar ludia !!
Mam script : function bbcode($str) { $BBCode = array("/\[img\](.*)\[\/img\]/is", "/\/is", "/\[b\](.*)\[\/b\]/is", "/\[u\](.*)\[\/u\]/is", "/\[i\](.*)\[\/i\]/is", "/\:D/is", "/\:S/is", "/\:\)/is", "/\:\(/is", "/\[citacia\](.*)\[\/citacia\]/is", "/\[url\=(.*?)\](.*?)\[\/url\]/is", "/\[email\](.*)\[\/email\]/is", "/\[riadok]/is"); $BBTag = array("<img src=\"$1\" align=\"\" alt=\"image\" border=\"0\"", "<hr style=\"color: lightgrey\">", "<strong>$1</strong>", "<u>$1</u>", "<i>$1</i>", "<img border=\"0\" alt=\"smile\" src=\"http://www.stt.yw.sk/desing/smiles/smile_3.png\" width=\"15\" height=\"15\">", "<img border=\"0\" alt=\"smile\" src=\"http://www.stt.yw.sk/desing/smiles/smile_4.png\" width=\"15\" height=\"15\">", "<img border=\"0\" alt=\"smile\" src=\"http://www.stt.yw.sk/desing/smiles/smile_1.png\" width=\"15\" height=\"15\">", "<img border=\"0\" alt=\"smile\" src=\"http://www.stt.yw.sk/desing/smiles/smile_2.png\" width=\"15\" height=\"15\">", "<div class=\"citacia\" style=\"background-color: #8BBED3; color: white;\">$1</div>", "<a href=\"http://www.stt.yw.sk/redi.php?u=$1\" target=\"_blank\" rel=\"nofollow\">$2</a>", "<a href=\"http://www.stt.yw.sk/?page=esend&pre=$1\" target=\"_blank\" rel=\"nofollow\">$1</a>", "<br />"); $str = preg_replace($BBCode, $BBTag, $str); return $str; } $str = $bwrite; $write = bbcode($str); Vsetko funguje ako ma. Ale ked zadam tu istu znacku v texte 2 alebo viac krat tak sa zacne na prvom tagu a skonci na poslednom. Ukazka : Ak dam : Tak mi vygeneruje : Prosim pomozte mi s tym. Diki J |
||
kubatt Profil |
#2 · Zasláno: 17. 1. 2010, 07:49:36 · Upravil/a: kubatt
jo ale je jasné že někde bude chyba v tom že se to neukončí asi to hledá poslední tag [/b] a první tag [b] :-D
použij toto je to lepší přehlednější a funguje to :) function BBcode($texto){ $a = array( '/\[br\]/is', '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[url\=(.*?)\](.*?)\[\/url\]/is', '/\[url\](.*?)\[\/url\]/is', '/\[align\=(left|center|right)\](.*?)\[\/align\]/is', '/\[img\](.*?)\[\/img\]/is', '/\[mail\=(.*?)\](.*?)\[\/mail\]/is', '/\[mail\](.*?)\[\/mail\]/is', '/\[font\=(.*?)\](.*?)\[\/font\]/is', '/\[size\=(.*?)\](.*?)\[\/size\]/is', '/\[color\=(.*?)\](.*?)\[\/color\]/is', '/\[codearea\](.*?)\[\/codearea\]/is', '/\[code\](.*?)\[\/code\]/is', '/\[p\](.*?)\[\/p\]/is', '/\[s\](.*?)\[\/s\]/is', '/\[icq=(.*?)\](.*?)\[\/icq\]/is', '/\*1/is', '/\*2/is' ); $b = array( '<br />', '<strong>$1</strong>', '<em>$1</em>', '<u>$1</u>', '<a href="$1" rel="nofollow">$2</a>', '<a href="$1" rel="nofollow" title="$1">$1</a>', '<div style="text-align: $1;">$2</div>', '<img src="$1" alt="" />', '<a href="mailto:$1">$2</a>', '<a href="mailto:$1">$1</a>', '<span style="font-family: $1;">$2</span>', '<span style="font-size: $1;">$2</span>', '<span style="color: $1;">$2</span>', '<textarea class="code_container" rows="30" cols="70">$1</textarea>', '<center><table width="98%" border="1" style="table-layout: fixed; border-collapse: collapse;"><tr><td bgcolor=#ff7f50><span class=small>Kód:</span></td></tr><tr><td><code><span style="color: green;">$1</span></code></td></tr></table></center>', '<p>$1</p>', '<s>$1</s>', '<a href="http://icq.scatter.cz/" title="Vlastní ICQ indikátory"><img src="http://icq.scatter.cz/status/icq_image.php?img=$1&icq=$2"border="0" alt="Vlastní ICQ indikátory"></a>$2', '<img src="smajly/1.gif" alt=":-)">', '<img src="smajly/2.gif" alt=":-D">' ); $texto = preg_replace ($a, $b, $texto); $texto = nl2br($texto); return $texto; } jinak nvm v čem je chyba ale skus ten můj scrípt :) |
||
JAAkub Profil |
#3 · Zasláno: 17. 1. 2010, 08:06:40
Teraz mi to zasa vobec nevygeneruje text. Diki aj tak :(
|
||
JAAkub Profil |
#4 · Zasláno: 17. 1. 2010, 08:14:26
Uz som to vyriesil !!!! - Nemoze tam byt (.*) ale (.*?)
Dakujem vam |
||
Časová prodleva: 14 let
|
0