PHP Function Iterator_To_Arrayy
php function iterator_to_array copies elements of an iterator into an array. Its second argument is a boolean value, indicating whether to use the iterator element keys as index. It is recommended to use this parameter if you want to avoid using the foreach loop for indexing the iterator.
The iterator_to_array function accepts any iterable as its first argument. Its return value is an array of the elements that the iterator has returned.
An iterable is any value that can be looped over with a foreach() loop. This includes arrays, as well as objects implementing the Traversable interface. The iterable pseudo-type was introduced in PHP 7.1.
It is possible to delegate a generator function, Traversable object, or array by using the yield from keyword. This allows you to create an outer generator, Traversable object, or array that yields values from the inner one and then stops execution once the inner generator has stopped generating its values.
The iterator_to_array() function now supports named parameters as well as positional arguments. A new optional argument, $use_keys, allows you to enable or disable the use of the iterator keys as indexes. When not enabled, the default key is a null string; if the iterator keys are used as indexes, they can be used as any standard PHP integer or float type. When enabled, NULL keys will be converted to an empty string, double keys will be truncated to their integer counterparts, resource keys will generate a warning and be converted to their resource ID, and boolean keys will be treated as an integer by the iterator.