Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The root node is not there because you are not using the RecursiveArrayIterator correctly.</p> <p>It's intended use is to have an array with multiple sub-arrays in any level and structure, and give this array into ONE instance of the RecursiveArrayIterator, and to iterate over everything, put this into a RecursiveIteratorIterator.</p> <p>That way, the entire array, including it's top level, will be iterated. </p> <p>Because you abused the RecursiveArrayIterator to be the carrier of information, the top level object is not iterated.</p> <p>Suggested easy example that has some nastyness, but demonstrates the principle:</p> <pre><code>$root = array( 'root_level' ); $block = array( 'first_level' ); $child = array( 'second_level' ); $child_of_child_a = array( 'third_level_a' ); $child_of_child_b = array( 'third_level_b' ); $child[] = $child_of_child_a; $child[] = $child_of_child_b ; $child_of_child_a[] = array(''); $child_of_child_a[] = array(''); $block[] = $child; $root[] = $block ; $storage = new \RecursiveIteratorIterator( new \RecursiveArrayIterator($root), RecursiveIteratorIterator::SELF_FIRST ); var_dump($root); foreach ($storage as $key=&gt;$value) { echo $key.": ".$value."\n"; } </code></pre> <p>Result output:</p> <pre><code>array(2) { [0] =&gt; string(10) "root_level" [1] =&gt; array(2) { [0] =&gt; string(11) "first_level" [1] =&gt; array(3) { [0] =&gt; string(12) "second_level" [1] =&gt; array(1) { ... } [2] =&gt; array(1) { ... } } } } 0: root_level 1: Array 0: first_level 1: Array 0: second_level 1: Array 0: third_level_a 2: Array 0: third_level_b </code></pre> <p>It's output is not quite the same, but my point is that you can iterate over the structure without having every single node to be an instance of the RecursiveArrayIterator. You can add anything that is either an array, or an object acting as an array, or an object that can usefully be iterated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload