static mapToArray()

The mapToArray() static method cast all elements of the iterable to an array

Example.php
<?php use kim\present\utils\arrays\ArrayUtils;

ArrayUtils::mapToArray([
    1,
    [2, 3],
    new class()extends \StdClass{public $arrayStart = 0;},
    new ArrayObject([1, 2, 3, 4, 5]),
    new ArrayIterator(["ArrayUtils", "mapToArray"])
]));
// expected output: Array(
//                      Array(1),
//                      Array(2, 3),
//                      Array("arrayStart" => 0),
//                      Array(1, 2, 3, 4, 5),
//                      Array("ArrayUtils", "mapToArray")
//)

Syntax

ArrayUtils::mapToArray(iterable $iterables) : array

Parameter

  • $iterable

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

Return value

  • A new array containing elements converted to an array.

References

Last updated