RecursiveIteratorIterator::setMaxDepth

(PHP 5 >= 5.1.0)

RecursiveIteratorIterator::setMaxDepthSet max depth

Description

public void RecursiveIteratorIterator::setMaxDepth ([ string $max_depth = -1 ] )

Set the maximum allowed depth.

Warning

This function is currently not documented; only its argument list is available.

Parameters

max_depth

The maximum allowed depth. -1 is used for any depth.

Return Values

No value is returned.

Errors/Exceptions

Emits an Exception if max_depth is less than -1.

Коментарии

Автор:
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);
2020-02-05 09:56:27
http://php5.kiev.ua/manual/ru/recursiveiteratoriterator.setmaxdepth.html
Автор:
to only access the current folder:
$max_depth = 0;
2020-02-15 14:53:35
http://php5.kiev.ua/manual/ru/recursiveiteratoriterator.setmaxdepth.html

    Поддержать сайт на родительском проекте КГБ