Converting preg_replace to preg_replace_callback for finding and replacing words with variables
问题 I have the following line of code: $message = preg_replace('/\{\{([a-zA-Z_-]+)\}\}/e', "$$1", $body); This replaces words surrounded by two curly brackets with variables of the same name. ie {{username}} gets replaced by $username. I am trying to convert it to use preg_replace_callback. This is my code so far based on Googling, but I'm not really sure what I am doing! The error_log output is showing the variable name including the curly brackets. $message = preg_replace_callback( "/\{\{([a-zA