# combine()

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

```php
<?php use kim\present\utils\arrays\ArrayUtils;

$arrayUtils = ArrayUtils::from(["first", "second", "third"]);

//General usage
$arrayUtils->combine([1, 2, 3]);
// expected output: ["first" => 1, "second" => 2, "third" => 3]

//Combine itself
$arrayUtils->combine();
// expected output: [
//   "first" => "first", 
//   "second" => "second", 
//   "third" => "third"
//]
```

{% endcode %}

## Syntax

```php
$arrayUtils->combine(iterable|null $valueArray = null) : ArrayUtils;
```

### Parameter

* `$valueArray` <img src="/files/-MKk9YjCz_YkVR1YiRy-" alt="" data-size="line">&#x20;

  > An array of elements to use as values.\
  > Default is `NULL`. If is null, Use itself.

### Return value

* &#x20;A combined array.

{% hint style="danger" %}
If the number of elements for each array isn't equal, It will be throw error
{% endhint %}

## Prefixing

```php
$arrayUtils->combineAs(iterable|null $valueArray = null) : array;
```

```php
ArrayUtils::combineFrom(iterable $from, iterable|null $valueArray = null) : ArrayUtils;
```

```php
ArrayUtils::combineFromAs(iterable $from, iterable|null $valueArray = null) : array;
```

## References

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


---

# 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/combine.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.
