我正在尝试合并多行字符串。我已经编写了用于合并没有“/n”字符但无法继续进行的数据的代码。我需要实现的是,将祖先节点与远程节点和本地节点进行比较,并逐行合并祖先节点中远程或本地的更改。每一行都应该在和更新之间进行比较$ancestor->$remote
和$ancestor->$local
更新祖先。
例如:第 3 行在远程而不是本地更改,因此第 3 行的所有更改都$remote
应该合并到 $ancestor 中,$local
如果第 6 行有更改,第 6 行也应该发生相同的情况。
另一个例子:
$ancestor = "This is a
normal comment"
$remtote = "This is not a
normal comment"
$local = "This is a
abnormal comment"
$expected_result = "This is not a
abnormal comment"