The from() static method creates a new, shallow-copied ArrayUtils instance from an iterable.
Last updated 4 years ago
<?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 is NULL . If is null, not execute map function.
NULL
A new ArrayUtils instance.
ArrayUtils