title: Group array values using loop and count with Twig
body: <p>I have a series of arrays that I need to group together. Here is an example of the incoming data:</p>
  
  <pre><code>[pet_name] =&gt; Array
      (
          [0] =&gt; Bob
          [1] =&gt; Buster
      )
  
  [type] =&gt; Array
      (
          [0] =&gt; cat
          [1] =&gt; dog
      )
  
  [age] =&gt; Array
      (
          [0] =&gt; 1
          [1] =&gt; 22
      )
  
  [gender] =&gt; Array
      (
          [0] =&gt; female
          [1] =&gt; male
      )
  </code></pre>
  
  <p>I am trying to group these to get the following result:</p>
  
  <pre><code>Pet #1
  Name: Bob
  Type: Cat
  Age: 1
  Gender: Female
  
  Pet #2
  Name: Buster
  Type: Dog
  Age: 22
  Gender: Male
  </code></pre>
  
  <p>I've tried the following methods without success:</p>
  
  <pre><code># Pet Info
  {% set total = pet_name|length %}
  {% set count = 0 %}
  
  {% for count in total %}
  # Pet #{{count + 1}}
  * Name: {{ attribute(pet_name, count) }}
  * Type: {{ attribute(type, count) }}
  * Age: {{ attribute(age, count) }}
  * Gender: {{ attribute(gender, count) }}
  {% set count = count + 1 %}
  
  {% endfor %}
  </code></pre>
  
  <p><strong>Second method:</strong></p>
  
  <pre><code># Pet Info
  {% set count = 0 %}
  
  {% for pet in pet_name %}
  # Pet #{{count}}
  * Name: {{ attribute(pet_name, count) }}
  * Type: {{ attribute(type, count) }}
  * Age: {{ attribute(age, count) }}
  * Gender: {{ attribute(gender, count) }}
  
  {% set count = count + 1 %} 
  {% endfor %}
  </code></pre>