Re: adding objects with + equal to array process

From: Date: Wed, 05 Jul 2000 11:19:02 +0000
Subject: Re: adding objects with + equal to array process
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-23552@lists.php.net to get a copy of this message
$obj1 = new Schrott; $obj2 = new Schrott; add_schrotts( $obj1, $obj2 );
I´m using the function below already, but it does not perform very well on large object. I only use it for objects of 'StdClass' created with settype() and I´m now playing around with create_function() to speed it up, but it would be consequent if we´d make it possible to "add" objects (perhaps only StdClass allowed) with the "+" operator, the array "adding" is very useful too... function &merge_objects(&$obj,&$obj2) { $vars=get_object_vars($obj2); foreach($vars AS $key => $value) { $obj->$key=$value; } } regards -- o----------0-¬---------O-·---¬----o---®-----o o O ° . | http://www.kiffen.de | pRoteçt y0ur bRaín |0 O ° ¤ ° · 0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ ° o © ° . · | psychedelic experience | gott@kiffen.de | O ° o ° o-¬--o--0-----©-·--O-----o-----0-¤----------o 0 ° · ° . ¤ ·

« previous php.dev (#23552) next »