I have a problem with php 5.5: when i use this code:
$source = preg_replace('/&#(\d+);/me', "utf8_encode(chr(\\1))", $source);
$source = preg_replace('/&#x([a-f0-9]+);/mei', "utf8_encode(chr(0x\\1))", $source);
return error
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead
I use with preg_replace_callback:
$source = preg_replace_callback('/&#(\d+);/me', function($m) { return utf8_encode(chr($m[1])); },$source);
$source = preg_replace_callback('/&#x([a-f0-9]+);/mei', function($m) { return utf8_encode(chr("0x".$m[1])); },$source);
it return warning:
Warning: preg_replace_callback(): Modifier /e cannot be used with replacement callback
What would be the correct code for achieving this?
e(modifier)that you were using within yourregexpattern along withpreg_replace_callback()function.Remove thate(modifier)from your regex. So simply your code looks like aspreg_replace_callback('/&#(\d+);/m', function($m) { return utf8_encode(chr($m[1])); },$source);- Narendrasingh Sisodia