blob: d36712233cd96246b1a997bfe23c35c3bfb8b900 [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001``length``
2==========
3
4The ``length`` filter returns the number of items of a sequence or mapping, or
5the length of a string.
6
7For objects that implement the ``Countable`` interface, ``length`` will use the
8return value of the ``count()`` method.
9
10For objects that implement the ``__toString()`` magic method (and not ``Countable``),
11it will return the length of the string provided by that method.
12
13For objects that implement the ``Traversable`` interface, ``length`` will use the return value of the ``iterator_count()`` method.
14
15.. code-block:: twig
16
17 {% if users|length > 10 %}
18 ...
19 {% endif %}