protected function arrayDepth($element, $depth = 1) {
        if (is_array($element)) {
            $maxDepth = $depth;
            foreach($element as $el) {
                $d = $this->arrayDepth($el, $depth + 1);
                if ($d > $maxDepth) {
                    $maxDepth = $d;
                }
            }
            return $maxDepth;
        } else {
            return $depth;
        }
    }
protected function arrayDepth($element, $depth = 1) {
        if (is_array($element)) {
            $maxDepth = $depth;
            foreach($element as $el) {
                $d = $this->arrayDepth($el, $depth + 1);
                if ($d > $maxDepth) {
                    $maxDepth = $d;
                }
            }
            return $maxDepth;
        } else {
            return $depth;
        }
    }
protected function arrayDepth ( $ element , $ depth = 1 ) { if ( is_array ( $ element ) ) { $ maxDepth = $ depth ; foreach ( $ element as $ el ) { $ d = $ this -> arrayDepth ( $ el , $ depth + 1 ) ; if ( $ d > $ maxDepth ) { $ maxDepth = $ d ; } } return $ maxDepth ; } else { return $ depth ; } }
Recursively called function to determine the depth of an array

@param  mixed $element Element to calculate depth on
@param  int   $depth   Depth level

@return int            Depth at this point
Recursively called function to determine the depth of an array