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]
$arrayUtils->unshift(mixed ...$values) : ArrayUtils;
$values
A values to unshift into array
- oneself back for method chaining.
$arrayUtils->unshiftAs(mixed ...$values) : array;
ArrayUtils::unshiftFrom(iterable $from, mixed ...$values) : ArrayUtils;
ArrayUtils::unshiftFromAs(iterable $from, mixed ...$values) : array;
Last modified 2yr ago