-2

I am getting

preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead

in one of the files in my application.

Near the below lines

   $str = preg_replace('/\&\#([0-9]+)\;/me', "code2utf('\\1',{$lo})",$str);
   $str = preg_replace('/\&\#x([0-9a-fA-F]+)\;/me', "codeHex2utf('\\1',{$lo})",$str);

How to convert the above preg_replace code to preg_replace_callback?

0

1 Answer 1

-1

Use anonymous functions

Check this answer Replace deprecated preg_replace /e with preg_replace_callback

Sign up to request clarification or add additional context in comments.

3 Comments

I have written my above code as $str = preg_replace_callback( "/\&\#([0-9]+)\;/me", function($m) { return code2utf($m[1],{$lo}); }, $str ); $str = preg_replace_callback( "/\&\#x([0-9a-fA-F]+)\;/me", function($m) { return codeHex2utf($m[1],{$lo}); }, $str ); I couldn't find deprecated issue but the page is blank. Is this the way I have to use preg_replace_callback?
Post the full code block
I have created a test block for your reference just have a look ideone.com/k1xE5T

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.