RecursiveDirectoryIterator to only scan 1 level
<p>how can I use something ilke RecursiveDirectoryIterator to only show the first level directories not sub directories.</p>

<p>such as</p>

<pre><code>/folder
  |-- folder-1
  |-- folder-2
    |-- sub-folder-1
    | -- subfolder-2
</code></pre>

<p>I would like to only show the folder names of folder-1 and folder-2 (and any other folders that may be added in the future dynamically), not any files.</p>

<p>In the end I would like to push each result into an array like this</p>

<pre><code>$clusters = new DirectoryIterator("/agents/");
        $cluster_array = array();

        foreach ($clusters as $fileinfo) {
            if ($fileinfo != "." &amp;&amp; $fileinfo != ".." &amp;&amp; $fileinfo != "conf") {
                array_push($cluster_array, $fileinfo);
            }
        }
        print_r($cluster_array);
</code></pre>

<p>edit: but the array comes out looking like this</p>

<pre><code>Array ( [0] =&gt; DirectoryIterator Object ( [pathName:SplFileInfo:private] =&gt; [glob:DirectoryIterator:private] =&gt; [subPathName:RecursiveDirectoryIterator:private] =&gt; ) )
</code></pre>

<p>but if i echo out the <code>$fileinfo</code> inside the <code>foreach</code> it show <code>cluster_1</code> which is what I want, but for some reason its not whats being pushed into the array.</p>
