arrayutils
Search
⌃K

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

  • $preserveKeys
    • 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 modified 2yr ago