static from()
The from() static method creates a new, shallow-copied ArrayUtils instance from an iterable.
Example.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))
ArrayUtils::from(iterable $iterable, ?callable $mapFn = null) : ArrayUtils
$iterable
Iterable object to convert to an array.$mapFn
Map function to call on every element of the array. Default isNULL
. If is null, not execute map function.
- A new
ArrayUtils
instance.
Last modified 2yr ago