In PHP, how can I merge all the property values of two objects? I am hoping for a built in function in PHP, else if anyone can show me an easy way of doing it.
See code under, where I have $objectA and $objectB which I want to become $obj_merged.
$objectA = (object) [];
$objectA->a = 1;
$objectA->b = 1;
$objectA->d = 1;
$objectB = (object) [];
$objectB->a = 2;
$objectB->b = 2;
$objectB->d = 2;
$obj_merged = [
'a' => 3,
'b' => 3,
'd' => 3
];