following problem,
i would like to replace a self-defined tag (like "<struct:5>") with the the return of a function that calls a databaseentry by the id (5).
my solution that doesn't really work:
$pattern = "/(<structure🙂(\d+)(>)/e";
$replacement = " loadStruct( \"$2\" ); ";
$result = preg_replace($pattern,$replacement, $code);
function loadStruct ($id) {
include("cfg.php");
$obj = mysql_fetch_array(mysql_query("select code from $mytable where id = '$id' LIMIT 1"));
if(!$obj) $code = "<!-- structure $id nicht vorhanden -->";
return $obj['code'];
}
the problem is, that nothing will be returned. the $id arrives successfully in the function LoadStruct. but the <struct:x> will not be replaced.
anyone any ideas?
thx flobo