1

I am trying to merge multi line strings. I have written the code for merging data which doesn't have "/n" character but unable to proceed with it. What I need to achieve is, comparing ancestor node with a remote node and local node and merging changes of either remote or local in ancestor line by line. Each line should be compared between $ancestor->$remote and $ancestor->$local and updated in ancestor.

For example: 3rd line is changed in remote but not local, so all changes from line 3 of $remote should be merged into $ancestor and same should happen with 6th line of $local if there is a change in line 6.

Another Example:

$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"
  • Can you please explain what it is doing? Pardon me if it's a silly question. I am very new to PHP. – Rakesh Verma Jun 15 '16 at 04:49
  • Pardon me if I have explained it in a wrong manner. What I am trying to achieve is something like this: $ancestor = "This is a normal comment" $local = "This is not a normal comment" $remote = "This is a abnormal comment" $expected_result = "This is not a abnormal comment" – Rakesh Verma Jun 15 '16 at 04:57
  • I misunderstood your problem. – Murad Hasan Jun 15 '16 at 05:02

0 Answers0