Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Set the internal pointer of an array to its last element
<?php end(array|object &$array): mixed
<?php         $versionsArray = iterator_to_array($versions);

        if (! empty($versionsArray)) {


            $latestVersion = end($versionsArray);

            $layers[$layerName] = $latestVersion->getVersion();

        }

    }
<?php                 $headers[$name] = is_array($values) ? $values : [$values];

            } else {


                $headers[$name] = is_array($values) ? end($values) : $values;

            }

        }
<?php             } else {



                $headers[$name] = is_array($values) ? end($values) : $values;

            }

        }
<?php         $output = explode("\n", trim($process->getOutput()));

        $lastLine = end($output);

        if (! empty($lastLine)) {

            $result = json_decode($lastLine, true, 512, JSON_THROW_ON_ERROR);

            if (json_last_error()) {