Can someone please help me with converting code
$file = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $file);
to use preg_replace_callback instead of it ?
Thanks
$file = preg_replace_callback('~&#([0-9]+);~', function($m) { return chr($m[1]); }, $file);
If you are on a version of php that doesn't support anonymous functions, you can do this instead:
function myfunction($m) { return chr($m[1]); }
$file = preg_replace_callback('~&#([0-9]+);~', 'myfunction', $file);
preg_replace should be preg_replace_callback shouldn't it :)preg_replace to preg_replace_callbackpreg_replace instead of preg_replace_callback.