I have a website which employs a PHP script to load some data from an HTML file and insert it in a link. So far it works perfectly:
$html = preg_replace('/(\d+):(\d+),/', '<a href="index.php?par1=$1&par2=$2">$1:$2</a>,', $html);
Now I want to upgrade it to insert tooltips in the links. The data is loaded from a database and I have a special function loadTooltip($param1, $param2) that does the job. The problem is how to call the function from within preg_replace(). This is the code that I have but it doesn't run the data simply showing the name of the function with the parameters. This is the code:
$html = preg_replace('/(\d+):(\d+),/', '<a href="index.php?par1=$1&par2=$2" titel="loadTooltip($1, $2)">$1:$2</a>,', $html);
So, how can I make it run?
preg_replace_callback