# unshift()

{% code title="Example.php" %}

```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]
```

{% endcode %}

## Syntax

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

### Parameter

* `$values`

  > A values to unshift into array

###

### Return value

* oneself back for method chaining.

## Prefixing

```php
$arrayUtils->unshiftAs(mixed ...$values) : array;
```

```php
ArrayUtils::unshiftFrom(iterable $from, mixed ...$values) : ArrayUtils;
```

```php
ArrayUtils::unshiftFromAs(iterable $from, mixed ...$values) : array;
```

## References

{% content-ref url="/pages/-MKmSpTJX9Uo5R5MdlG4" %}
[push()](/methods/c/push.md)
{% endcontent-ref %}

{% embed url="<https://www.php.net/manual/en/function.array-unshift.php>" %}

{% embed url="<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://arrayutils.docs.present.kim/methods/c/unshift.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
