• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

RegEx

Status
Für weitere Antworten geschlossen.

=]ReDHeaD[=

Mitglied
Ich hab ein echt fettes Problem und zwar will ich eine Zitatfunktion in ein Forum einbauen, es ist nichts anderes als [quote ][/ quote].
([quote = ...] [/quo te])

der RegEx dazu ist:

PHP:
$rows['inhalt'] = preg_replace("/\[quote\](.*)\[\/quote\]/iUs","<div style=\"padding:10px;\"<b>Zitat</b><div style=\"width:75%; padding-left:3px; padding-top:10px; border:1px inset; background:#E1E4F2;\">$1</div></div>",$rows['inhalt']);
naja das klapp auch alles, ich kann sooft zitieren, wie ich will, aber sobold ich hinter das letzte [/quote] was schreibe, beispiel:


[quote = ReDHead]bla bla[/quote ]
bist du ein idiot?




kommt nur scheixXxe bei raus, er interpretiert irgendwie die hälfte davon ^^

ich zeigs euch mal:

www.gp-gamers.de/fehler.jpg



das wird von:

Code:
[quote= SplasH ][ quote= SplasH][ quote]sdsd[ / quote]asd[ /qu ote]asd[/qu ote]
erzeugt.
 
Werbung:
Versuch es mal so
PHP:
<?php
$text="[quote=SplasH][quote=SplasH][quote]sdsd[/quote]asd[/quote]asd[/quote]";
$reqex = Array();
$neu = Array();

//Ersetzen von [quote]
$regex[] = "#\[quote\]#isU";
$neu[] = "<div style=\"padding:10px;\"<b>Zitat</b>
             <div style=\"width:75%;padding-left:3px; padding-top:10px; 
             border:1px inset; background:#E1E4F2;\">";

//Ersetzen von [quote=...]
$regex[] = "#\[quote=(.*)\]#isU";
$neu[] = "<div style=\"padding:10px;\"<b>Zitat von $1</b>
             <div style=\"width:75%;padding-left:3px; padding-top:10px; 
             border:1px inset; background:#E1E4F2;\">";

//Ersetzen von [/quote]
$regex[] = "#\[/quote\]#isU";
$neu[] = "</div>";

$text = preg_replace($regex[0],$neu[0],$text);
$text = preg_replace($regex[1],$neu[1],$text);
$text = preg_replace($regex[2],$neu[2],$text);
echo $text;
?>
 
Werbung:
hast du folgendes gemacht?
PHP:
$text = $rows['inhalt']

Hab das bei mir getestet und es geht einwandfrei.
 
Status
Für weitere Antworten geschlossen.
Zurück
Oben