Something like this should work:
json_encode(
array_merge(
json_decode($a, true),
json_decode($b, true)
)
)
or the same as one-liner:
json_encode(array_merge(json_decode($a, true),json_decode($b, true)))
array_merge in official PHP documentation
json_decode in official PHP documentation
EDIT: try adding true
as second parameter to json_decode. That’ll convert objects to associative arrays.
EDIT 2: try array-merge-recursive
and see my comment below. Sorry have to log out now 🙁
This looks like a full correct solution: https://stackoverflow.com/a/20286594/1466341