K
K
Kirill2020-10-30 21:36:36
Drupal
Kirill, 2020-10-30 21:36:36

How to output the correct array from the loop?

node_field has four items 27, 35, 42 and 52

{% set iFor = [] %}
  {% for item in items %}
    {% set iFor = iFor|merge([item]) %}
  {% endfor %}


Outputs 27354252 and I need it to be ["27", "35", "42", "52"] is it possible to wrap it in a loop? or already make it out of it, directly in Twig

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
antiden, 2020-11-03
@donda

{% set iFor = [] %}
{% for item in items %}
       {% set values = item|merge([item]) %}
{% endfor %}

{% for value in values %}
      {{ value }}
{% endfor %}

Maybe something like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question