# 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="https://2976351099-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKYhyHaArG9Gsnmdxc8%2F-MKk9I82AGQBHkmwnVvk%2F-MKk9YjCz_YkVR1YiRy-%2FBADGE_OPTIONAL.svg?alt=media&#x26;token=3fbbac84-2f1b-40af-a991-b2eff659866a" 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>" %}
