RecursiveIteratorIterator::setMaxDepth

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

RecursiveIteratorIterator::setMaxDepthDefine profundidade máxima

Descrição

public RecursiveIteratorIterator::setMaxDepth(int $maxDepth = -1): void

Define a profundidade máxima permitida.

Aviso

Esta função não está documentada; apenas a lista de argumentos está disponível.

Parâmetros

maxDepth

A profundidade máxima permitida. -1 é usado para qualquer profundidade.

Valor Retornado

Nenhum valor é retornado.

Erros/Exceções

Emite uma Exception se maxDepth for menor que -1.

adicione uma nota

Notas Enviadas por Usuários (em inglês) 2 notes

up
1
Anonymous
5 years ago
to only access the current folder:$max_depth = 0;
up
1
Anonymous
5 years ago
I didn't understand what to do with this statement:RecursiveIteratorIterator::setMaxDepth ([ int $max_depth = -1 ] ) : voidSo, after finding the answer, this is how you incorporate it (for anyone else who was stuck for a while like me!):// define the depth of the tree to which you want to search// where -1 = show all layers below the parent// and 1 = show the first layer, etc, etc$max_depth = -1;  // set the path to the directory$this_directory// do the search$recursive = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this_directory));// now adjust the contents to your desired depth$recursive->setMaxDepth($max_depth);
To Top