[Twig] Count the number of elements in the array

I think there are a cases where you want to get the number of elements in an array.
Twig uses a filter to get the number of elements.

Officail: Documentation — Length

{% if users|length > 10 %}
    ...
{% endif %}

 
Use length.
Well, that’s it.


Leave a Reply 0

Your email address will not be published.

6 + fourteen =