Es que tengo que anidar funciones o si no, ya me dirás tu como envío la id de la noticia por cada post.
Edit:
Al final, algo así termina de funcionarme :D
Código:
function BBCodeExpand($string, $idn) {
GLOBAL $idn;
function mi_callback($match){
return ProcessQuote($match[1], $GLOBALS['idn']); // el número
}
function ProcessQuote($match, $idn){
# Buscamos el post del quote
ConexionDB();
# Get Relacionadas
$query = mysql_query('SELECT mensaje FROM noticias_comentarios WHERE idn = "'.$idn.'" AND idp = "'.$match.'"');
$check = mysql_num_rows($query);
if($check == 0) {
return '<a class="tooltip" href="#'.$match.'" ref="El mensaje #'.$match.' no existe"><strong>#'.$match.'</strong></a>';
}else{
$fetch = mysql_fetch_array($query);
return '<a class="tooltip" href="#'.$match.'" ref="'.$fetch['mensaje'].'"><strong>#'.$match.'</strong></a>';
}
}
$string = preg_replace_callback('/#(\d+)\b/', 'mi_callback', $string);
return $string;
}
echo BBCodeExpand($string, $idn);
Gracias por todo! :D