arrayutils
Search…
static mapToArray()
The mapToArray() static method cast all elements of the iterable to an array
Example.php
1
<?php use kim\present\utils\arrays\ArrayUtils;
2
3
ArrayUtils::mapToArray([
4
1,
5
[2, 3],
6
new class()extends \StdClass{public $arrayStart = 0;},
7
new ArrayObject([1, 2, 3, 4, 5]),
8
new ArrayIterator(["ArrayUtils", "mapToArray"])
9
]));
10
// expected output: Array(
11
// Array(1),
12
// Array(2, 3),
13
// Array("arrayStart" => 0),
14
// Array(1, 2, 3, 4, 5),
15
// Array("ArrayUtils", "mapToArray")
16
//)
Copied!

Syntax

1
ArrayUtils::mapToArray(iterable $iterables) : array
Copied!

Parameter

  • $iterable
    An iterable containing an iterable. It converted to an array.

Return value

  • A new array containing elements converted to an array.

References

PHP: Iterables - Manual