For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

References

push()

Last updated