title: Localize markers in PHP Array
body: <p>This is quite basic, but I am missing a puzzle piece.</p>
  
  <p>I have a multidimensional PHP array that - among other things - contains some strings. I would like to translate special strings in this array based on a translation table or array in PHP.</p>
  
  <pre><code>$r = array(
      0 =&gt; 'something',
      1 =&gt; array(
         'othertext' =&gt; '1000 {{animals}} and {{cars}}',
         'anytext' =&gt; '400 {{cars}}',
      )
  );
  </code></pre>
  
  <p>In $r, now I would like to replace {{animals}} with another string that is stored in a separate array.</p>
  
  <p>Here it is:</p>
  
  <pre><code>$translations = array(
      'animals' =&gt; array('Tiere','animaux','bestie'),
      'cars' =&gt; array('Autos','voitures','macchine'),
  );
  </code></pre>
  
  <p>Now let's set the language / column we want to look up</p>
  
  <pre><code>$langId = 0;
  </code></pre>
  
  <p><strong>And now, take $r, look for all key that are wrapped in {{}}, look them up in $translations and replace them with key[$langId], so in return we get:</strong></p>
  
  <pre><code>$r = array(
      0 =&gt; 'something',
      1 =&gt; array(
         'othertext' =&gt; '1000 Tiere',
         'anytext' =&gt; '400 Autos',
      )
  );
  </code></pre>
  
  <p>ehm... how's that done?</p>
  
  <p>PS: the marker {{}} is random, could be anything robust</p>