Jump to content


Photo

preg_replace bbcode. code in code...


  • Please log in to reply
2 replies to this topic

#1 DarkendSoul

DarkendSoul
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 28 August 2006 - 06:57 AM

$code = preg_replace("#\[QUOTE\](.*)\[/QUOTE\]#si", "<table id='quote' align='center'><tr><td class='title'>QUOTE </td></tr><tr><td class='body'>\\1</td></tr></table>", $code);

Using the above code, when inputting things like the following:

[ quote] TEXT [ quote] TEXT [ quote] TEXT [ quote] TEXT [/quote] [/quote] [/quote] [/quote]

it will only output

<table id='quote' align='center'><tr><td class='title'>QUOTE </td></tr><tr><td class='body'> TEXT [ quote] TEXT [ quote] TEXT [ quote] TEXT [/quote] [/quote] [/quote] </td></tr></table>

I would like to do like it does in this website and output

[quote] TEXT [quote] TEXT [quote] TEXT [quote] TEXT [/quote] [/quote] [/quote] [/quote]

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 28 August 2006 - 07:35 AM

<?php
while(preg_match("#\[QUOTE\](.*)\[/QUOTE\]#si", $code)!=0){
$code = preg_replace("#\[QUOTE\](.*)\[/QUOTE\]#si", "<table id='quote' align='center'><tr><td class='title'>QUOTE </td></tr><tr><td class='body'>\\1</td></tr></table>", $code);
}
?>

I think this will work :)

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 DarkendSoul

DarkendSoul
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 28 August 2006 - 08:29 PM

thank you. that worked :D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users