<?php
$responseOne = '{
"success": true,
"msg": "",
"obj": [
{
"id": 1,
"remark": "D"
},
{
"id": 159,
"remark": "mssdss"
}
]
}';
$responseTwo = '{
"success": true,
"msg": "",
"obj": [
{
"id": 14,
"remark": "tttt"
},
{
"id": 56,
"remark": "ok"
}
]
}';
$mergedResponse = json_encode(
array_merge(
json_decode($responseOne, true)['obj'],
json_decode($responseTwo, true)['obj']
)
);
// Print the merged JSON response
var_dump($mergedResponse);
- Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- string(102) "[{"id":1,"remark":"D"},{"id":159,"remark":"mssdss"},{"id":14,"remark":"tttt"},{"id":56,"remark":"ok"}]"
preferences:
87.41 ms | 407 KiB | 5 Q