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

        $firstKey = self::getFirstKey($array);
        $first = $array[$firstKey];

        if (!$firstLevelOnly && is_array($first)) {
            $first = self::getFirstElement($first, $firstLevelOnly);
        }

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

        $firstKey = self::getFirstKey($array);
        $first = $array[$firstKey];

        if (!$firstLevelOnly && is_array($first)) {
            $first = self::getFirstElement($first, $firstLevelOnly);
        }

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

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

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