merge two php objects code example Example: merge two objects in php Click to copyarray_merge((array)json_decode($data1), (array) json_decode($data2));