这是我引用帖子的bbcode(12345是原帖的ID):
[quote=12345] ... citation ... [/quote]
我想显示这样的引用:
<blockquote>
<a href="">Username</a> at 2012-09-12 11:00 a.m. (<a href="">original</a>):
... citation ...
</blockquote>
想法(伪代码):
$bbcode_content = "[quote=12345] ... citation ... [/quote]";
// 1. get the $post_id
$post_id = replace('/\[quote\=(.*?)\]/is','$1', $bbcode_content);
// 2. select the post data from databse
$post_obj = $DB->select("SELECT `author`, `timestamp` FROM `posts` WHERE id=".$post_id);
// 3. build an extended bbcode tag
$bbcode_content = "[quote post_id={$post_id} timestamp={$post_obj->timestamp} author={$post_obj->author}]";
// 4. bbcode to html
$html = replace("[quote post_id=(*) timestamp=(*) author=(*)]", '<blockquote><a href="">$1</a> at '.date("Y-m-d h:i", $2).' (<a href="forum/post/$3">original</a>)', $bbcode_content);
$html = replace("[/quote]", "</blockquote>", $html);
问题:
我有点困惑。你会如何解决这个问题?
提前致谢!