Removing the first quotes
Posted: Sat Jan 29, 2005 6:51 am
You know how its done on many forums where say you have a quote tree of about 4 people and when someone trys to add another one it gets stripped to one.
How would I do?
I have the code to display the quotes (below) but Im thinking somehow using preg_match_all and then some form of regex to remove the first ones leaving the last.
How would I do?
I have the code to display the quotes (below) but Im thinking somehow using preg_match_all and then some form of regex to remove the first ones leaving the last.
Code: Select all
<?PHP
$forumz_post = "їquote=by azz0r at 28th Jan 8:15pm] їquote=by Jack at 28th Jan 3:50pm] їquote=by azz0r at 28th Jan 12:18pm] :lol: :lol: ї/quote]
Wow, that's <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> hilarious.
Remind me to :lol: next time you fall off a 6-foot high structure onto your face and can't breathe. ї/quote]
:lol: :lol:
:gtfo: ї/quote]";
preg_match_all('/(?<!\\\\)\їquote(?::\w+)?\]/i', $forumz_post, $quote_open);
preg_match_all('/(?<!\\\\)\їquote(?::\w+)?=(?:"|"|'')?(.*?)ї"'']?(?:"|"|'')?\]/i', $forumz_post, $quote_opens);
preg_match_all('/(?<!\\\\)\ї\/quote(?::\w+)?\]/i', $forumz_post, $qe);
$qopen = count($quote_openї0]) + count($quote_opensї0]);
$qend = count($qeї0]);
if($qopen == $qend)
{$forumz_post = str_replace('їquote]', "<table cellspacing="1" cellpadding="4" class="table">
<tr><td class="headbars">Quote</td></tr>
<tr><td class="cell">", $forumz_post);
$forumz_post = preg_replace('/(?<!\\\\)\їquote(?::\w+)?=(?:"|"|'')?(.*?)ї"'']?(?:"|"|'')?\]/i',
"<table cellspacing="1" cellpadding="4" class="table">
<tr><td class="headbars">Quote (\\1)</td></tr>
<tr><td class="cell">", $forumz_post);
$forumz_post = str_replace('ї/quote]', '</td></tr></table>', $forumz_post);}
echo $forumz_post;