Comment on page
combine()
The combine() method returns new array by using one array for keys and another for values
Example.php
<?php use kim\present\utils\arrays\ArrayUtils;
$arrayUtils = ArrayUtils::from(["first", "second", "third"]);
//General usage
$arrayUtils->combine([1, 2, 3]);
// expected output: ["first" => 1, "second" => 2, "third" => 3]
//Combine itself
$arrayUtils->combine();
// expected output: [
// "first" => "first",
// "second" => "second",
// "third" => "third"
//]
$arrayUtils->combine(iterable|null $valueArray = null) : ArrayUtils;
$valueArray
An array of elements to use as values. Default isNULL
. If is null, Use itself.
- A combined array.
If the number of elements for each array isn't equal, It will be throw error
$arrayUtils->combineAs(iterable|null $valueArray = null) : array;
ArrayUtils::combineFrom(iterable $from, iterable|null $valueArray = null) : ArrayUtils;
ArrayUtils::combineFromAs(iterable $from, iterable|null $valueArray = null) : array;
Last modified 3yr ago