static from()
The from() static method creates a new, shallow-copied ArrayUtils instance from an iterable.
<?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))
Syntax
ArrayUtils::from(iterable $iterable, ?callable $mapFn = null) : ArrayUtils
Parameter
$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.
Return value
A new
ArrayUtils
instance.
References
Last updated