reverse()

The reverse() method reverses an array

Example.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"]

Syntax

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

Parameter

    • When set to TRUE keys will be preserved. Default is FALSE which will re-index the chunk numerically

Return value

  • A reversed array.

Prefixing

$arrayUtils->reverseAs(bool $preserveKeys = false) : array;
ArrayUtils::reverseFrom(iterable $from, bool $preserveKeys = false) : ArrayUtils;
ArrayUtils::reverseFromAs(iterable $from, bool $preserveKeys = false) : array;

References

Last updated