<p>Is there a way to create an array of items, fetch them with .all() and loop through them?  For example:</p>

<pre><code>{% set array = array|merge([block]) %}

{% for block in gallery.all() %}
{% endfor %}  
</code></pre>

CC BY-SA 4.0
2019-07-29T18:18:26.077Z
`.all()` lives in the element query classes, not on an array.  If you've already got your results in array format, why not just loop through them directly?
Brad Bell
CC BY-SA 4.0
2019-07-30T06:02:11.153Z
I was just curious to know if there is a way to do so, but looping through as an array is fine.
nmsdvid
<craft3><forloop>
How to create an array of items and fetch them with .all()?
# How to create an array of items and fetch them with .all()?

(Asked by: username_0 on 2019-07-29)

Is there a way to create an array of items, fetch them with .all() and loop through them?  For example:
{% set array = array|merge([block]) %}

{% for block in gallery.all() %}
{% endfor %}

**Tags:** craft3, forloop
> **Comments:**
> **username_1**: `.all()` lives in the element query classes, not on an array.  If you've already got your results in array format, why not just loop through them directly?  
> **username_0**: I was just curious to know if there is a way to do so, but looping through as an array is fine.  

---

## 0 answers

