Jump to content

preg_replace bbcode. code in code...


DarkendSoul

Recommended Posts

$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]
Link to comment
https://forums.phpfreaks.com/topic/18875-preg_replace-bbcode-code-in-code/
Share on other sites

[code]<?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);
}
?>[/code]

I think this will work :)

Orio.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.