title: Symfony2 - How to iterate through an associative array in Twig and eliminate duplicates?
body: <p>I am working on a Report which is mapped with Docrtrine I have an entity DL01, and I want to access specific array key &amp; values to display the output in the following format</p>
  
  <p>My Associative array {{ Dump() }} of DL01_data is below</p>
  
  <pre><code>array(2) { 
   [0]=&gt; array(4) { 
           ["zoneName"]=&gt; string(10) "DENMARK"
           ["rank"]=&gt; int(85)
           ["actSanctList"]=&gt; NULL 
           ["offDate"]=&gt; object(DateTime)#5717 (3) { ["date"]=&gt; string(19) "2010-10-25 00:00:00" ["timezone_type"]=&gt; int(3) ["timezone"]=&gt; string(13) "Europe/Berlin" } } 
  </code></pre>
  
  <p>My controller returns this</p>
  
  <p><code>return $this-&gt;render('TestBundle:Test:DL01.html.twig', array('form' =&gt;   $form-&gt;createView(), 'DL01_data' =&gt; $DL01));</code></p>
  
  <p>I want to display the result of the report in twig in the following format, such that the records are grouped together and displayed one after the another in a nested for loop.
  (See pictures)</p>
  
  <p>Current output 
  <img src="https://i.stack.imgur.com/1YFY0.jpg" alt="enter image description here"></p>
  
  <p>How can i group records together nested in this format, eliminating the duplicates? </p>
  
  <p><img src="https://i.stack.imgur.com/RNoin.jpg" alt="enter image description here"></p>
  
  <p>Twig
  I am displaying the report in Twig, in this manner </p>
  
  <pre><code>    {% for DL01_line in DL01_data %}
          &lt;tr&gt;
               &lt;td&gt; {{ DL01_data[0].zoneName }} &lt;/td&gt;
               &lt;td&gt; {{ DL01_data[0].Rank }} &lt;/td&gt;
              &lt;td&gt;{{ DL01_line.actSanctList }}&lt;/td&gt;
              &lt;td&gt;{{ DL01_line.offDate|date('Y-m-d') }}&lt;/td&gt;
          &lt;/tr&gt;
      {% endfor %}
  </code></pre>