I'm trying to replace my deprecated code with preg_replace()
and the /e
modifier with preg_replace_callback()
.
But right now I run into an error which I don't know why I get it.
Old code:
function getItem( $item, $tmp ){
return preg_replace('/\{([A-Za-z0-9_]+)}/e', '$item["$1"]', $tmp);
}
new code:
function getItem( $item, $tmp ) {
return preg_replace_callback('/\{([A-Za-z0-9_]+)}/', function ($m){
return $item[$m[1]]; //Line 129
}, $tmp);
}
Error:
Notice: Undefined variable: item in /home/merttugoto/public_html/admin/inc/dynamic.cls.php on line 129