PHP - Concatenating 2 objects -
i have 2 objects.
here output of objects when print them out print_r method of php.
oject #1;
stdclass object ( [id] => 1 [portal_id] => 1 [name=> nevzat ) object #2;
stdclass object ( [surname] => yilmaz) i want concatenate these 2 objects each other @ end of process need object contains of variables of 2 objects;
stdclass object ( [id] => 1 [portal_id] => 1 [name=> nevzat [surname] => yilmaz )
a simple way temporarily cast objects arrays, merge arrays, case resulting array stdclass object.
$merged = (object) array_merge((array) $object_a, (array) $object_b);
Comments
Post a Comment