a Sensio Labs Product

The flexible, fast, and secure
template engine for PHP

Filters » reverse

Questions & Feedback

License

Creative Commons License Twig documentation is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.

reverseΒΆ

New in version 1.6: Support for strings has been added in Twig 1.6.

The reverse filter reverses a sequence, a mapping, or a string:

1
2
3
4
5
6
7
{% for use in users|reverse %}
    ...
{% endfor %}

{{ '1234'|reverse }}

{# outputs 4321 #}

Note

It also works with objects implementing the Traversable interface.

This website is powered by PHP and Twig. The Twig logo is © 2010-2012 Sensio Labs