> For the complete documentation index, see [llms.txt](https://arrayutils.docs.present.kim/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://arrayutils.docs.present.kim/methods/c/reverse.md).

# reverse()

{% code title="Example.php" %}

```php
<?php use kim\present\utils\arrays\ArrayUtils;

$arrayUtils = ArrayUtils::from(["orange", "banana", "apple", "raspberry", "kiwi"]);


$arrayUtils->reverse();
// expected output: ["kiwi", "raspberry", "apple", "banana", "orange"]
```

{% endcode %}

## Syntax

```php
$arrayUtils->reverse(bool $preserveKeys = false) : ArrayUtils;
```

### Parameter

* `$preserveKeys` <img src="/files/-MKk9YjCz_YkVR1YiRy-" alt="" data-size="line">&#x20;
  * When set to **`TRUE`** keys will be preserved. \
    Default is **`FALSE`** which will re-index the chunk numerically

### Return value

* A reversed array.

## Prefixing

```php
$arrayUtils->reverseAs(bool $preserveKeys = false) : array;
```

```php
ArrayUtils::reverseFrom(iterable $from, bool $preserveKeys = false) : ArrayUtils;
```

```php
ArrayUtils::reverseFromAs(iterable $from, bool $preserveKeys = false) : array;
```

## References

{% embed url="<https://www.php.net/manual/en/function.array-reverse.php>" %}
