I would like to have a regular expression that takes
[QUOTE=3]
and transforms it into
<div class="quoted"><div class="quotation-author">Originally written by <strong>AUTHOR_WITH_ID=3</strong></div>
I got it almost right, but I’m unable to pass a variable to a function that gets author name.
$comment = preg_replace('/\[\s*QUOTE=(\d+)\s*\]/i', '<div class="quoted"><div class="quotation-author">Originally written by <strong>'.get_comment_author((int)'$1').'</strong></div>', $comment);
The replacement:
does not happen dynamically; it is evaluated, then passed as an argument. Use
preg_replace_callbackto call a function for each match as follows: