To solve the problem, as in the question, the goal is to read the user ID marked in the content and retrieve the user name from the database.
Problem, only "$1" can be read out, but the value cannot be obtained.
function usvid($csse,$uvid){
global $db,$DBprefix;
echo $csse.$uvid; $query_usersid="select * from ".$DBprefix."users where Uid='$csse' order by Uid desc"; $sql_usersid=mysql_query($query_usersid); while ($usersid=mysql_fetch_array( $sql_usersid)){
$bbs_H=$usersid['UserName']; }
return $bbs_H;
}
function vubb($str){
$str=preg_replace("/\[userid=(.+?)\](.+?)\[\/userid\]/is",usvid("$1",'$2'),$str);
return $str;
}
echo vubb("[userid=10000]xy[/userid]");
The second parameter of preg_replace can only be a string or array, the function usage is wrong
Change to the correct preg_replace_callback, the second parameter is the callback function
Rewrite the example as follows (not tested whether it is correct or not):
Only 4 lines have been changed. The author can try again. Please forgive me if there are any mistakes.
Thanks for the invitation!
Then, are there any questions?
My interpretation of your sql is:
I tested it and the output sql is the same as what you requested
select * from users where Uid='10000' order by Uid desc