Gerrit
Gerrit

Reputation: 2677

Check if array variable has mor than x values?

I'm using twig and want to check if the given variable xyz has more than x entries. How is that possible?

Thanks!

Upvotes: 2

Views: 2128

Answers (2)

Mark
Mark

Reputation: 1754

Yes, the length filter is the way to go.

{% if xyz | length > x %}
   {% do something %}
{% endif %}

Upvotes: 4

Gerrit
Gerrit

Reputation: 2677

Okay, I think xyz|length will work.

Upvotes: 0

Related Questions