I have a series of arrays that I need to group together. Here is an example of the incoming data:
[pet_name] => Array
(
[0] => Bob
[1] => Buster
)
[type] => Array
(
[0] => cat
[1] => dog
)
[age] => Array
(
[0] => 1
[1] => 22
)
[gender] => Array
(
[0] => female
[1] => male
)
I am trying to group these to get the following result:
Pet #1
Name: Bob
Type: Cat
Age: 1
Gender: Female
Pet #2
Name: Buster
Type: Dog
Age: 22
Gender: Male
I've tried the following methods without success:
# 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 %}
Second method:
# 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 %}