RecursiveIteratorIterator::getDepth

(PHP 5, PHP 7, PHP 8)

RecursiveIteratorIterator::getDepth Определяет текущую глубину рекурсии

Описание

public RecursiveIteratorIterator::getDepth(): int
Внимание

Функцию пока не задокументировали; для знакомства доступен только список аргументов.

Список параметров

У этой функции нет параметров.

Возвращаемые значения

Текущая глубина рекурсии навигации.

Добавить

Примечания пользователей 1 note

up
4
spicypixel at gmail dot com
7 years ago
Example to only return directories that are a specified depth in a tree:<?phpfunction directory_mapper($path){    $maxDepth = 3;    $minDepth = 3;    $iterator = new RecursiveIteratorIterator(        new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS),        RecursiveIteratorIterator::SELF_FIRST,        RecursiveIteratorIterator::CATCH_GET_CHILD// Ignore "Permission denied"    );    $iterator->setMaxDepth($maxDepth);    $paths = array($path);    foreach ($iterator as $path => $dir) {        if ($iterator->getDepth() >= $minDepth) {            if ($dir->isDir()) {                $paths[] = $path;            }        }    }    array_shift($paths);    return $paths;}?>
To Top