protected function deep_merge_recursive($arrays)
    {
        $result = array();

        foreach ($arrays as $array)
        {
            foreach ($array as $key => $value)
            {
                if (is_integer($key))
                {
                    $result[] = $value;
                }
                elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value))
                {
                    $result[$key] = $this->deep_merge_recursive(array($result[$key], $value));
                }
                // handle embeded object with object value
                elseif (isset($result[$key]) && is_object($result[$key]) && is_object($value))
                {
                    $result[$key] = (object)$this->deep_merge_recursive(array((array)$result[$key], (array)$value));
                }
                // handle embeded object with array value
                elseif (isset($result[$key]) && is_object($result[$key]) && is_array($value))
                {
                    $result[$key] = (object)$this->deep_merge_recursive(array((array)$result[$key], $value));
                }
                else
                {
                    $result[$key] = $value;
                }
            }
        }

        return $result;
    }
protected function deep_merge_recursive($arrays)
    {
        $result = array();

        foreach ($arrays as $array)
        {
            foreach ($array as $key => $value)
            {
                if (is_integer($key))
                {
                    $result[] = $value;
                }
                elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value))
                {
                    $result[$key] = $this->deep_merge_recursive(array($result[$key], $value));
                }
                // handle embeded object with object value
                elseif (isset($result[$key]) && is_object($result[$key]) && is_object($value))
                {
                    $result[$key] = (object)$this->deep_merge_recursive(array((array)$result[$key], (array)$value));
                }
                // handle embeded object with array value
                elseif (isset($result[$key]) && is_object($result[$key]) && is_array($value))
                {
                    $result[$key] = (object)$this->deep_merge_recursive(array((array)$result[$key], $value));
                }
                else
                {
                    $result[$key] = $value;
                }
            }
        }

        return $result;
    }
protected function deep_merge_recursive ( $ arrays ) { $ result = array ( ) ; foreach ( $ arrays as $ array ) { foreach ( $ array as $ key => $ value ) { if ( is_integer ( $ key ) ) { $ result [ ] = $ value ; } elseif ( isset ( $ result [ $ key ] ) && is_array ( $ result [ $ key ] ) && is_array ( $ value ) ) { $ result [ $ key ] = $ this -> deep_merge_recursive ( array ( $ result [ $ key ] , $ value ) ) ; } // handle embeded object with object value elseif ( isset ( $ result [ $ key ] ) && is_object ( $ result [ $ key ] ) && is_object ( $ value ) ) { $ result [ $ key ] = ( object ) $ this -> deep_merge_recursive ( array ( ( array ) $ result [ $ key ] , ( array ) $ value ) ) ; } // handle embeded object with array value elseif ( isset ( $ result [ $ key ] ) && is_object ( $ result [ $ key ] ) && is_array ( $ value ) ) { $ result [ $ key ] = ( object ) $ this -> deep_merge_recursive ( array ( ( array ) $ result [ $ key ] , $ value ) ) ; } else { $ result [ $ key ] = $ value ; } } } return $ result ; }
but also handle embeded objects
but also handle embeded objects