twig in array 1

twig in array

{% set array = [] %}
{% for item in items %}
    {% set array = array|merge([{ title: item.title, ... }]) %}
{% endfor %}

Here is what the above code is Doing:
1. Create an empty array
2. Loop through the items
3. Merge the item’s title into the array

Similar Posts