iterator_to_array

Supported Versions: PHP 5 >= 5.1.0, PHP 7, PHP 8
Copy the iterator into an array
<?php iterator_to_array(Traversable|array $iterator, bool $preserve_keys = true): array
<?php             is_object($this->value) && method_exists($this->value, 'toString') => $this->value->toString(),

            $this->value instanceof \Illuminate\Testing\TestResponse => $this->value->getContent(), // @phpstan-ignore-line

            is_array($this->value) => json_encode($this->value, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT),

            $this->value instanceof Traversable => json_encode(iterator_to_array($this->value), JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT),

            $this->value instanceof JsonSerializable => json_encode($this->value->jsonSerialize(), JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT),

            is_object($this->value) && method_exists($this->value, 'toArray') => json_encode($this->value->toArray(), JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT),

            default => InvalidExpectationValue::expected('array|object|string'),
<?php                 $preserveKeysForArrayIterator = $datasets[$index] instanceof Generator

                    && is_string($datasets[$index]->key());



                $datasets[$index] = iterator_to_array($datasets[$index], $preserveKeysForArrayIterator);

            }



            foreach ($datasets[$index] as $key => $values) {