I want to merge json arrays with another json arrays which accessed from URL.
example1.json
"contents":[
{
"idSentence":[
118077
],
"idParagraph":16424
},
{
"idSentence":[
10402,
85562
],
"idParagraph":16427
},
]
For example, http://www.example.com/2016/04/news/idS/10402/f/json will returns:
"idSentence":10402,
"sentence":"Compact but strong storms known as supercells reach Oklahoma, "
and http://www.example.com/2016/04/news/idS/85562/f/json will returns:
"idSentence":85562,
"sentence":"which also brought many violent storms to the states of Kansas, Arkansas, and Tennessee."
My question is, how can I combine that jsons to shown like this with PHP & JS?
Id Paragraph Id Sentence Sentence
16427 10402 Compact but strong storms known as supercells reach Oklahoma,
16427 85562 which also brought many violent storms to the states of Kansas, Arkansas, and Tennessee
There is a lot of sentence and paragraph, so I need an efficient way to do this. My idea is doing iterative process by retrieve the id sentence in every id paragraph, and call the json url of sentence that correspond to the id sentence, combine both of it, and show it to table
$jsonText = file_get_contents("example.json");
$jsonUrl = "http://www.example.com/2016/04/news/idS/idSentence/f/json"
$arr = json_decode($jsonText, true);
//This is the part of iterative process & call correspond id sentence
//This is the part of combining process and show it to table
I'm a relative beginner to json, so I'm still confused about how to solve this problem. Please help, thank you.