As a rule of thumb, you should prefer an preg_replace_callbackexpression modifier /e. But depending on what you want to do, there are many workarounds.
You can split the string expression:
'"{"."$"."$2"."}"', $tmp
Or use an alternate placeholder syntax and exit {$so that it is not interpreted as a variable in double quotes:
'"{\\\$\2}"'
(No, I didn’t know this, I was just messing around.)
mario source
share