Ich mache eine Website, auf der Benutzer einige BBcodes und meinen eigenen BBcode eingeben können.
aber ich habe ein Problem, wenn ein Anführungszeichen innerhalb eines Anführungszeichens steht
zum Beispiel :
[Zitat] [quote] Text eins [/zitat] Text zwei [/quote]
erwartetes Ergebnis:
\----------------------------
| |
| ------------------------ |
| |text one | |
| ------------------------ |
| |
|text two |
----------------------------
das tatsächliche Ergebnis:
\----------------------------
|\[quote\]text one |
----------------------------
text two \[/quote\]
mein Code:
function bbcode($replace)
{
$bbcode = array(
"'\[center\](.*?)\[/center\]'is" => "<center>\\1</center>",
"'\[left\](.*?)\[/left\]'is" => "<div style='text-align: left;'>\\1</div>",
"'\[right\](.*?)\[/right\]'is" => "<div style='text-align: right;'>\\1</div>",
"'\[pre\](.*?)\[/pre\]'is" => "<pre>\\1</pre>",
"'\[b\](.*?)\[/b\]'is" => "<b>\\1</b>",
"'\[quote\](.*?)\[/quote\]'is" => "<div class='qrap'><small>Quote:</small><div class='quote'><br><br>\\1</div></div>",
"'\[i\](.*?)\[/i\]'is" => "<i>\\1</i>",
"'\[enter]'is" => "<br>",
"'\[u\](.*?)\[/u\]'is" => "<u>\\1</u>",
"'\[s\](.*?)\[/s\]'is" => "\\1",
"'\[move\](.*?)\[/move\]'is" => "<marquee>\\1</marquee>",
"'\[url\](.*?)\[/url\]'is" => "<a href='\\1' target='_BLANK'>\\1</a>",
"'\[url=(.*?)\](.*?)\[/url\]'is" => "<a href=\"\\1\" target=\"_BLANK\">\\2</a>",
"'\[img\](.*?)\[/img\]'is" => "<img border=\"0\" src=\"\\1\">",
"'\[img=(.*?)\]'" => "<img border=\"0\" src=\"\\1\">",
"'\[email\](.*?)\[/email\]'is" => "<a href='mailto: \\1'>\\1</a>",
"'\[size=(.*?)\](.*?)\[/size\]'is" => "<span style='font-size: \\1;'>\\2</span>",
"'\[font=(.*?)\](.*?)\[/font\]'is" => "<span style='font-family: \\1;'>\\2</span>",
"'\[color=(.*?)\](.*?)\[/color\]'is" => "<span style='color: \\1;'>\\2</span>",
"'\[youtube\](.*?)\[/youtube\]'is" => "<object height='350' width='425'><param name='movie' value='http://www.youtube.com/v/\\1'><embed src='http://www.youtube.com/v/\\1' type='application/x-shockwave-flash' wmode='transparent' height='350' width='425'></object>",
"'\[quote=(.*?)\](.*?)\[/quote\]'is" => "<div class='qrap'><small>Quote:</small><div class='quote'>Originally posted by: <b>\\1</b><br><br>\\2</div></div>",
"'\[spoiler\](.*?)\[/spoiler\]'is" => "<div class='srap'>
<div><b>Spoiler</b>: <input type='button' onclick='spoiler(this)' value='SHOW' class='sbutton'></div>
<div>
<div class='spoiler' style='display:none;'>\\1</div>
</div>
</div>",
"'\[spoiler=(.*?)\](.*?)\[/spoiler\]'is" => "<div class='srap'>
<div><b>Spoiler</b> for <i>\\1</i>: <input type='button' onclick='spoiler(this)' value='SHOW' class='sbutton'></div>
<div>
<div class='spoiler' style='display:none;'>\\2</div>
</div>
</div>",
"'\[quotepost=(.*?);(.*?)\](.*?)\[/quote\]'is" => "<div class='qrap'><small>Quote:</small><div class='quote'>Originally posted by: <b>\\1</b> (<a href=\"viewcomment.php?id=\\2\" target='_BLANK'>Go to Post</a>)<br><br>\\3</div></div>"
);
$replace = preg_replace(array_keys($bbcode), array_values($bbcode), $replace);
return $replace;
}
?>
Kann mir jemand helfen? Danke im Voraus