/** * Flush the remaining entries left in the iterator. * * @param boolean $return If true, return entries. Only returns entries * on the current level. * @param boolean $sublevel Only flush items in current sublevel? * * @return array The entries if $return is true. */ public function flushIterator($return = true, $sublevel = true) { $out = array(); if ($return) { $this->_nextModify = array('level' => $sublevel ? $this->_level : 0, 'out' => array()); $this->next(); $out = $this->_nextModify['out']; $this->_nextModify = array(); } elseif ($sublevel && $this->_level) { $this->_nextModify = array('level' => $this->_level); $this->next(); $this->_nextModify = array(); } else { $this->_stream->end(); $this->_stream->getChar(); $this->_current = $this->_key = $this->_level = false; } return $out; }