{ $return = NULL; foreach ($this->composite as &$object) { if (isset($object->{$name})) { $return =& $object->{$name}; break; } } unset($object); return $return; } public function &all() { $a = new stdClass(); foreach ($this->composite as $k => $v) { foreach ($v as $k1 => $v1) { $a->{$k1} = $v1; } } return $a; } } $a = array('a' => '1', 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5, 'f' => 6, 'g' => 7); $b = array('h' => 8, 'i' => 9, 'j' => 10, 'k' => 11, 'l' => 12, 'm' => 13); $c = (object) $a; $d = (object) $b; $obj3 = new objects(true); $obj3->merge($c, $d); echo '<pre>'; var_dump($obj3->all()); echo '</pre>';