0

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 wrong?

2
  • 1
    I won't answer because regular expressions are opaque to me, but It looks like you are replacing the text in the first pass, and the second pass, there's no match. Commented Jul 6, 2011 at 16:06
  • YES! thats it! post an answer and I will accept it if you want :) Commented Jul 6, 2011 at 16:25

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.