开发者

Problem with preg_replace /e modifier when used in a loop

开发者 https://www.devze.com 2023-03-18 16:33 出处:网络
When I use following code: $text = /*some text*/; $langs = array(\'en\', \'pl\'); foreach($langs as $lang) {

When I use following code:

$text = /*some text*/;
$langs = array('en', 'pl');
foreach($langs as $lang) {
    $text = preg_replace("/I18N\('(.+?)'\)/e", 'func("$1", "$lang")', $text);
}

preg_replace only works for the first array element ('en' in this example). What am I doing wro开发者_开发知识库ng?


I [won't] will answer though regular expressions are opaque to me: it looks like you are replacing the text in the first pass, and the second pass, there's no match

0

精彩评论

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