PHP 8.6.0 Beta 1 is available for testing

RecursiveIteratorIterator::setMaxDepth

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

RecursiveIteratorIterator::setMaxDepthDefine la profundidad máxima

Descripción

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

Define la profundidad máxima permitida.

Advertencia

Esta función está actualmente no documentada; solo la lista de sus argumentos está disponible.

Parámetros

maxDepth

La profundidad máxima permitida. -1 será utilizado para una profundidad infinita.

Valores devueltos

No se retorna ningún valor.

Errores/Excepciones

Emite una Exception si maxDepth es inferior a -1.

Found A Problem?

Learn How To Improve This PageSubmit a Pull RequestReport a Bug
+add a note

User Contributed Notes 2 notes

up
1
Anonymous
6 years ago
to only access the current folder:
$max_depth = 0;
up
1
Anonymous
6 years ago
I didn't understand what to do with this statement:
RecursiveIteratorIterator::setMaxDepth ([ int $max_depth = -1 ] ) : void
So, 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);
+add a note

AltStyle によって変換されたページ (->オリジナル) /