public static function countMaxDepth(array $array)
    {
        $maxDepth = 1;
        foreach ($array as $element) {
            $depth = 1;
            if (is_array($element)) {
                $depth += self::countMaxDepth($element);
            }
            if ($depth > $maxDepth) $maxDepth = $depth;
        }

        return $maxDepth;
    }
public static function countMaxDepth(array $array)
    {
        $maxDepth = 1;
        foreach ($array as $element) {
            $depth = 1;
            if (is_array($element)) {
                $depth += self::countMaxDepth($element);
            }
            if ($depth > $maxDepth) $maxDepth = $depth;
        }

        return $maxDepth;
    }
public static function countMaxDepth ( array $ array ) { $ maxDepth = 1 ; foreach ( $ array as $ element ) { $ depth = 1 ; if ( is_array ( $ element ) ) { $ depth += self :: countMaxDepth ( $ element ) ; } if ( $ depth > $ maxDepth ) $ maxDepth = $ depth ; } return $ maxDepth ; }
Counts maximum array depth recursively

@param array $array

@return int
Counts maximum array depth recursively