I am trying to replace this:
$source = preg_replace('/&#(\d+);/me', "utf8_encode(chr(\\1))", $source);
with preg_replace_callback
and an anonymous function.
What would be the right way to do this?
Try the following:
preg_replace_callback(
'/&#(\d+);/m',
function ($matches) {
return utf8_encode(chr($matches[1]));
},
$source
);