public function replace(array $array, $recursively = false)
    {
        if (true === $recursively) {
            return new static(array_replace_recursive($this->elements, $array));
        }

        return new static(array_replace($this->elements, $array));
    }
public function replace(array $array, $recursively = false)
    {
        if (true === $recursively) {
            return new static(array_replace_recursive($this->elements, $array));
        }

        return new static(array_replace($this->elements, $array));
    }
public function replace ( array $ array , $ recursively = false ) { if ( true === $ recursively ) { return new static ( array_replace_recursive ( $ this -> elements , $ array ) ) ; } return new static ( array_replace ( $ this -> elements , $ array ) ) ; }
Replace values in the current array with values in the given one
that have the same key.

@param array $array Array of replacing values
@param bool $recursively Whether array will be replaced recursively or no

@return ArrayImitator A new array with the same keys but new values
Replace values in the current array with values in the given one that have the same key .