title: Insert a $key as an variable in a foreach loop in PHP
body: <p>I have this array:</p>
  
  <pre><code>$lista_agregados = array('po' =&gt; '0', 'brita' =&gt; '0');  
  </code></pre>
  
  <p>And these arrays:</p>
  
  <pre><code>$po = array(0 =&gt; array('qt' =&gt; 12, 'total' =&gt; 1234),  
              1 =&gt; array('qt' =&gt; 45, 'total' =&gt; 13224));
  $brita = array(0 =&gt; array('qt' =&gt; 54, 'total' =&gt; 124),  
              1 =&gt; array('qt' =&gt; 18, 'total' =&gt; 224));  
  </code></pre>
  
  <p>I want to use a loop instead of explicit operations for every key in <code>$lista_agregados</code>:  </p>
  
  <pre><code>$somatorio_mensal['po'] = $po[0]['total'] + $po[1]['total'];
  $somatorio_mensal['brita'] = $brita[0]['total'] + $brita[1]['total'];
  </code></pre>
  
  <p>This is what I have so far:  </p>
  
  <pre><code>foreach ($lista_agregados as $key =&gt; $value) {
      $somatorio_mensal["'$key'"] = $key[0]['total'] + $key[1]['total'];
  }  
  </code></pre>
  
  <p>The problem is that <code>$key[0]</code> is interpreted as <code>po[0]</code> instead of <code>$po[0]</code>. 
  Is there a way to make this work?</p>