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     public function setMultiple($values, $ttl = null): bool

    {

        return $this->putMany(is_array($values) ? $values : iterator_to_array($values), $ttl);

    }
<?php             return $this->source;

        }



        return iterator_to_array($this->getIterator());

    }
<?php             $items instanceof WeakMap => throw new InvalidArgumentException('Collections can not be created using instances of WeakMap.'),

            $items instanceof Enumerable => $items->all(),

            $items instanceof Arrayable => $items->toArray(),

            $items instanceof Traversable => iterator_to_array($items),

            $items instanceof Jsonable => json_decode($items->toJson(), true),

            $items instanceof JsonSerializable => (array) $items->jsonSerialize(),

            $items instanceof UnitEnum => [$items],
<?php         $this->give(function ($container) use ($tag) {

            $taggedServices = $container->tagged($tag);



            return is_array($taggedServices) ? $taggedServices : iterator_to_array($taggedServices);

        });

    }
<?php     public function files($directory, $hidden = false)

    {

        return iterator_to_array(

            Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory)->depth(0)->sortByName(),

            false

        );

    }
<?php     public function allFiles($directory, $hidden = false)

    {

        return iterator_to_array(

            Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory)->sortByName(),

            false

        );

    }
<?php         }



        if ($other instanceof Traversable) {

            return iterator_to_array($other);

        }



        return (array) $other;