In PHP, I am struggling to merge two json objects ( $old and $new ) with nested values:
echo "OLD: ".$old;
echo "NEW: ".$new;
Result:
OLD: {"4":{"deu":1, "eng":1, "fra":1}}
NEW: {"4":{"deu":1, "eng":2}}
Expected result I needed:
{"4":{"deu":1, "eng":2, "fra":1}}
Attempts:
Tried json_decode() and array_merge() but got a json result with missing key 4
I got these kind of results:
{{"deu":1, "eng":2, "fra":1}}
//or
[{"deu":1, "eng":1, "fra":1},{"deu":1, "eng":2}]
As you can see the key 4 is missing from the result