PHP - Concatenating 2 objects
php
Solution
A simple way would be to temporarily cast the objects to arrays, merge those arrays, then case the resulting array back to a `stdClass` object.
$merged = (object) array_merge((array) $object_a, (array) $object_b);
Problem
I have 2 objects. Here is the output of the objects when I print them out with `print_r` method of the PHP. Oject #1; ``` stdClass Object ( [id] => 1 [portal_id] => 1 [name=> NEVZAT ) ``` Object #2; ``` stdClass Object ( [surname] => YILMAZ) ``` I want to concatenate these 2 objects to each other so at the end of the process I need an Object which contains all of the variables of the 2 objects; ``` stdClass Object ( [id] => 1 [portal_id] => 1 [name=> NEVZAT [surname] => YILMAZ ) ```