title: Looping with twig
body: <p>How do I do this with twig?</p>
  
  <pre><code>    foreach($estimate_data AS $year =&gt; $month) {
          foreach ($month AS $monthNo =&gt; $estimates) {
            $chart_data .= "['". $year ."/".$monthNo."',"; 
            foreach (array(0, 1, 3, 5, 8, 13, 20) AS $est){
                $chart_data .= (isset($estimates[$est]) ? $estimates[$est] : 0) .",";
            }
            $chart_data .= "],\n";
          }
      }
  </code></pre>
  
  <p>This is what I have so far, but I'm struggling with the inner foreach and checking the existence of an element in the array:</p>
  
  <pre><code>      {% for year, month in chart_data %}
          {% for month_no, estimates in month %}
            ['{{year}}/{{month_no}}',
            {% for i in [0, 1, 2, 3, 5, 8, 13, 20]  %}
              {% if estimates %}
              {{estimates[i]}} ,
              {% endif %}
            {% endfor %}
          {% endfor %}
        {% endfor %}
  </code></pre>