PHP: preg_replace to preg_replace_callback conversion problem

16 views Asked by At

I'm no PHP expert but I am trying the process of converting preg_replace() items with 'e' to preg_replace_callback() and found many samples that I though I understood, but apparently don't because it doesn't work. Here's one with a problem for sure:

Original:

$_rowHTML .= @preg_replace("/\[(.+)\]/Uie", "\$_callBackResult['\\1']", $_rowTemplate);

My converted version that doesn't work:

$_rowHTML .= @preg_replace_callback("/\[(.+)\]/Ui", function($m){ return $_callBackResult[$m[1]];}, $_rowTemplate);

What did I do wrong?

Thanks!!

0

There are 0 answers