Jump to content

parsing bbcode quote tag


vbnullchar

Recommended Posts

With a callback funktion

ex
[CODE]<?php

function quote_it($str, $id) {


if(preg_match('~\[quotes~i', $str)) {

$str = "<div style=\"border: 1px solid #000\" id=\"$id\">\n";

} else {

$str = "\n</div>\n";

}

return $str;

}

$string = '[quotes id=2][quotes id=1]one[/quotes] two [/quotes]';

echo preg_replace('~(\s*\[quotes\s+id=(\d+)]\s*)|(\s*\[/quotes]\s*)~ise', 'quote_it("\\1", "\\2")', $string);

?>[/CODE]

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.