replace()
The replace() method replaces elements from passed arrays into the first array
<?php use kim\present\utils\arrays\ArrayUtils;
$arrayUtils = ArrayUtils::from(["orange", "banana", "apple", "raspberry", "kiwi"]);
$arrayUtils->replace([0 => "pineapple", 4 => "cherry"]);
// expected output: ["pineapple", "banana", "apple", "raspberry", "cherry"]Syntax
$arrayUtils->replace(iterable ...$iterables) : ArrayUtils;Parameter
$iterablesArrays to replace.
Return value
A replaced array.
Prefixing
$arrayUtils->replaceAs(iterable ...$iterables) : array;ArrayUtils::replaceFrom(iterable $from, iterable ...$iterables) : ArrayUtils;ArrayUtils::replaceFromAs(iterable $from, iterable ...$iterables) : array;References
Last updated