开发者

i preg_replace and get only last char of the statement. help

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 开发者_StackOverflow社区$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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜