arrayutils
Search…
⌃K

unshift()

The unshift() method all similar to push(), but this push elements onto the start of array
Example.php
<?php use kim\present\utils\arrays\ArrayUtils;
​
$arrayUtils = ArrayUtils::from(range(1,5));
​
//Unshift 0 and 10
$arrayUtils->unshift(0, 10);
// expected output: [0, 10, 1, 2, 3, 4, 5]

Syntax

$arrayUtils->unshift(mixed ...$values) : ArrayUtils;

Parameter

  • $values
    A values to unshift into array

​

Return value

  • oneself back for method chaining.

Prefixing

$arrayUtils->unshiftAs(mixed ...$values) : array;
ArrayUtils::unshiftFrom(iterable $from, mixed ...$values) : ArrayUtils;
ArrayUtils::unshiftFromAs(iterable $from, mixed ...$values) : array;

References

​
​
Last modified 2yr ago