This is a simple way to merge two object with PHP. This way only works with objects containing fields and not methods.


$obj_merged = (object) array_merge((array) $cats, (array) $catnames);