Beispiel #1
0
 function __array_merge($arr1, $arr2)
 {
     $arResult = $arr1;
     foreach ($arr2 as $key2 => $val2) {
         if (!array_key_exists($key2, $arResult)) {
             $arResult[$key2] = $val2;
             continue;
         } elseif ($val2 == $arResult[$key2]) {
             continue;
         } elseif (!is_array($arResult[$key2])) {
             $arResult[$key2] = array($arResult[$key2]);
         }
         $arResult[$key2] = __array_merge($arResult[$key2], $val2);
     }
     return $arResult;
 }
Beispiel #2
0
 function __array_merge($arr1, $arr2, $deep = false)
 {
     $arResult = $arr1;
     static $ii = 0;
     $ii++;
     $deep = $deep == false ? 0 : $deep;
     foreach ($arr2 as $key2 => $val2) {
         if (!array_key_exists($key2, $arResult)) {
             $arResult[$key2] = $val2;
             continue;
         } elseif ($val2 == $arResult[$key2]) {
             continue;
         } elseif (!is_array($arResult[$key2])) {
             $arResult[$key2] = array($arResult[$key2]);
         }
         $deep++;
         $arResult[$key2] = __array_merge($arResult[$key2], $val2, $deep);
     }
     return $arResult;
 }