PHP merge multiple objects 2

From , 4 Years ago, written in PHP, viewed 54 times.
URL https://pastebin.vip/view/b922ede9
  1. function mergeObject($source, $dest, $overWrite = false) {
  2.     $sourceName = get_class($source);
  3.     foreach ($source as $key => $aProp) {
  4.        if(!$overWrite && isset($dest->$key)) {
  5.         $propName = $sourceName . "_" . $key;
  6.         $dest->$propName = $aProp;
  7.        } else {
  8.         $dest->$key = $aProp;
  9.        }
  10.     }
  11.     return $dest;
  12. }

Reply to "PHP merge multiple objects 2"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website