src/Utilities/Arrays.php
public static function getLastElement(array $array, $firstLevelOnly = true)
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($array)) {
            return null;
        }

        $last = end($array);

        if (!$firstLevelOnly && is_array($last)) {
            $last = self::getLastElement($last, $firstLevelOnly);
        }

        return $last;
    }
public static function getLastElement(array $array, $firstLevelOnly = true)
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($array)) {
            return null;
        }

        $last = end($array);

        if (!$firstLevelOnly && is_array($last)) {
            $last = self::getLastElement($last, $firstLevelOnly);
        }

        return $last;
    }
public static function getLastElement ( array $ array , $ firstLevelOnly = true ) { /*
         * No elements?
         * Nothing to do
         */ if ( empty ( $ array ) ) { return null ; } $ last = end ( $ array ) ; if ( ! $ firstLevelOnly && is_array ( $ last ) ) { $ last = self :: getLastElement ( $ last , $ firstLevelOnly ) ; } return $ last ; }
Returns the last element of given array

It may be last element of given array or the totally last element from the all elements (last element of the
latest array).

@param array $array          The array to get the last element of
@param bool  $firstLevelOnly (optional) If is set to true, last element is returned. Otherwise - totally
last element is returned (last of the latest array).
@return mixed
Returns the last element of given array