
| Current Path : /var/www/html1/testsite/vendor/twig/twig/doc/filters/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html1/testsite/vendor/twig/twig/doc/filters/length.rst |
``length``
==========
.. versionadded:: 1.33
Support for the ``__toString()`` magic method has been added in Twig 1.33.
The ``length`` filter returns the number of items of a sequence or mapping, or
the length of a string.
For objects that implement the ``Countable`` interface, ``length`` will use the
return value of the ``count()`` method.
For objects that implement the ``__toString()`` magic method (and not ``Countable``),
it will return the length of the string provided by that method.
For objects that implement the ``IteratorAggregate`` interface, ``length`` will use the return value of the ``iterator_count()`` method.
.. code-block:: twig
{% if users|length > 10 %}
...
{% endif %}