---
title: "Reverse ViewHelper <f:reverse>"
manual: "Fluid Explained"
version: "main"
permalink: "https://docs.typo3.org/permalink/fluid:typo3fluid-fluid-reverse"
source: "ViewHelpers/Fluid/Reverse.rst"
rendered: "2026-11-16T10:01:33+00:00"
---

# Reverse ViewHelper `<f:reverse>` {#typo3fluid-fluid-reverse}

The ReverseViewHelper returns an array with its items in reverse order.
String keys are always preserved, numeric keys only if `preserveKeys`
is set.

This ViewHelper mimicks PHP's `array_reverse()` function.

Iterators like generators can yield the same key more than once. Only the
last item per key is used, like with PHP's `iterator_to_array()`
function.

## Examples {#examples}

### Reverse an array {#reverse-an-array}

Given `items = ['a', 'b', 'c']`:

```php
<f:reverse value="{items}" />

```

```php
['c', 'b', 'a']
```

### Preserve numeric keys {#preserve-numeric-keys}

```php
<f:reverse value="{items}" preserveKeys="{true}" />

```

```php
[2 => 'c', 1 => 'b', 0 => 'a']
```

### Output the items in reverse order {#output-the-items-in-reverse-order}

```php
{items -> f:reverse() -> f:join(separator: ', ')}

```

```text
c, b, a
```

Go to the source code of this ViewHelper: [ReverseViewHelper.php (GitHub)](https://github.com/TYPO3/Fluid/blob/main/src/ViewHelpers/ReverseViewHelper.php).

**Arguments**

The following arguments are available for the reverse ViewHelper:

-   **preserveKeys**

    -   *Type:* boolean
    -   *Default:* false

    If true, numeric keys are preserved. String keys are always preserved.

-   **value**

    -   *Type:* array

    The array to reverse
