How would I merge both JSON arrays and then sort the value of ID so that the result displays the highest number to the lowest number?
For example, my desired output from the script below would be:
- 1 - Jimbo
- 2 - Bob
- 6 - Luke
- 12 - Chris
- 16 - Jonas
- 36 - Sam
Here's my JSON arrays:
$json1 ='
{
"error": "trueee",
"info": {
"collections": [{
"ID": "1"
"Name": "Jimbo"
}, {
"ID": "36"
"Name": "Sam"
}, {
"ID": "2",
"Name": "Bob"
}]
}
}
';
$json2 ='
{
"error": "trueee",
"info": {
"collections": [{
"ID": "12"
"Name": "Chris"
}, {
"ID": "6"
"Name": "Luke"
}, {
"ID": "16"
"Name": "Jonas"
}]
}
}
';