Counting the number of elements in array

前端 未结 3 642
你的背包
你的背包 2021-02-03 16:56

I am looking to count the number of entries I have in an array in Twig. This is the code I\'ve tried:

{%for nc in notcount%}
{{ nc|length }}
{%endfor%}
         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-03 17:42

    Just use the length filter on the whole array. It works on more than just strings:

    {{ notcount|length }}
    

提交回复
热议问题