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     $layers = [];

    foreach ($results as $layerName => $result) {

        $versions = $result->getLayerVersions(true);

        $versionsArray = iterator_to_array($versions);

        if (! empty($versionsArray)) {


            $latestVersion = end($versionsArray);