I've some PHP functions that given two JSON files, merge them into one to meet certain specs. However I need to add a feature, using PHP, that merges content strings of both files. These strings may have text that is different in some point between them.
Example
JSON-1
"elements":[
...
{
"type": "text",
"content": "It went up the tree! Then climbed down.",
},
...
]
JSON-2
"elements":[
...
{
"type": "text",
"content": "I saw your cat. It went up the tree! Then it run away!",
},
...
]
And I need the merged file to be like
JSON-MERGED
"elements":[
...
{
"type": "text",
"content": "<la>I saw your cat.</la> It went up the tree! <po>Then climbed down.<po> <li> Then it run away!</li>",
},
...
]
Any idea on how could I do this? I thought of "exploding" the content in an array and then iterate over each other to see what matches. But then, similar words, in different context would match and mess up the code!