Re: merging objects
| From: | Ernest E Vogelsinger | Date: | Tue, 08 Apr 2003 09:49:09 +0000 |
| Subject: | Re: merging objects | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142828@lists.php.net to get a copy of this message | ||
At 11:44 08.04.2003, Diana Castillo said:
--------------------[snip]--------------------
>is there any way to add one object to the end of another ? (they are the
>same type of objects)
--------------------[snip]--------------------
What do you really want to achieve? If the objects are "of the same type",
attributes of one would overwrite existing attributes of the other object.
You may cast an object as an array. As such you may loop through it as here:
foreach ((array)$obj1 as $key => $value)
$obj2->$key = $value;
This would "merge" the objects, overwriting existing attributes in $obj2
with the values of $obj1.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/