another solution which seems more reliable and which will take all the possibilities
function &getElements($recurse = false){
if (!$recurse) {
return $this->_elements;
} else {
$ret = array();
$count = count($this->_elements);
for ($i = 0; $i < $count; $i++) {
if ( is_object( $this->_elements[$i] ) ) {
if (!$this->_elements[$i]->isContainer()) {
$ret[] =& $this->_elements[$i];
} else {
$elements =& $this->_elements[$i]->getElements(true);
$count2 = count($elements);
for ($j = 0; $j < $count2; $j++) {
$ret[] =& $elements[$j];
}
unset($elements);
}
}
}
return $ret;
}
}