Preg_replace_callback function
$val = Preg_replace ("/\[([^\[\]]*) \]/eis", "'. '). Str_replace (' $ ', ' \$ ', ' \\1 ') ", $val);
This sentence with the Preg_replace_callback function how to rewrite it to ask for advice under
------Solution--------------------
$val = Preg_replace_callback ("/\[([^\[\]]*) \]/eis", function ($match) {return str_replace (' $ ', ' \$ ', $match)}, $val);
------Solution--------------------
$val = Preg_replace_callback (
'/\[([^\[\]]*) \]/is ',
function ($matches) {
Return '. '. Str_replace (' $ ', ' \$ ', $matches [1]);
},
$val
);
Echo $val;
------Solution--------------------
References:
the last place in the middle of the code include which line is not clear how to change
$pattern = '/
. *?
/s ';
$replacement = "' {include file= '. Strtolower (' \\1 '). '} ';
$source = Preg_replace_callback ($pattern, $replacement, $source);
- -
Still the same is a string ah or the original way to do it
------Solution--------------------
$replacement = function ($matches) {return ' {include file= '. Strtolower ($matches [1]). '}';};