# static from()

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

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

var_export(ArrayUtils::from([3,6,9]));
// expected output: ArrayUtils(array(3, 6, 9))

var_export(ArrayUtils::from([1, 2, 3], function($x){ return $x + $x; }));
// expected output: ArrayUtils(array(2, 4, 9))
```

{% endcode %}

## Syntax

```php
ArrayUtils::from(iterable $iterable, ?callable $mapFn = null) : ArrayUtils
```

### Parameter

* `$iterable`&#x20;

  > Iterable object to convert to an array.
* `$mapFn`  <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;

  > Map function to call on every element of the array.\
  > Default is `NULL` . If is null, not execute map function.

### Return value

* A new `ArrayUtils` instance.

## References

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