I have a script that replaces all BBCODES in comments to HTML.
I have managed to convert all the simple codes except the username code [user="max"]
because I need to grab more user information such as user reputation & user online status from the database.
$bbextended = array(
"/\[url](.*?)\[\/url]/i" => "<a href=\"http://$1\" title=\"$1\">$1</a>",
"/\[user=(.*?)\]/i" => "<div class=\"user\"> <a href=\"/user/$1\" title=\"$1\">$1</a><span> $USER REPUTATION </span></div>",
);
foreach($bbextended as $match=>$replacement){
$bbtext = preg_replace($match, $replacement, $bbtext);
}
Since preg_replace
replaces matches inside it's function, I cannot get the username to grab other user information from the database.