to only access the current folder:$max_depth = 0;
(PHP 5 >= 5.1.0, PHP 7, PHP 8)
RecursiveIteratorIterator::setMaxDepth — 最大の深さを設定する
許可される最大の深さを設定します。
この関数は、 現在のところ詳細な情報はありません。引数のリストのみが 記述されています。
maxDepth
許可される最大の深さ。-1
を指定すると無制限にできます。
値を返しません。
maxDepth
が -1
より小さい場合に例外が発生します。
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);