Use array_replace_recursive

array_merge_recursive, would create arrays if there was a custom value for an index set, thus causing errors.