我preg_replace并只获取该语句的最后一个字符。 救命

I've got a terrible problem. There are a lot of constructions like {{SOME_WORDS}} in my string and I want to change it for $lang['some_word']. For this reason I use something like:

$cache=preg_replace('/({{)+([A-Z_])+(}})/u','$2',$cache);

and got only last char of SOME_WORDS "S". The next problem is to put $lang[strtolower($2)] into preg_replace second argument. Or there could be another solution?

you need to put the + inside the parentheses. like this:

$cache=preg_replace('/({{)+([A-Z_]+)(}})/u','$2',$cache);

try this:

$cache = preg_replace("/\{\{(\w+)\}\}/e", "strtolower($1)", $cache);