Append Data to JSON - array_merge

11 Views Asked by At

I'm trying to append some data to json, but the output ([[],[],[]]) isn't what I expected
Here's my code:

$utenti = json_decode('{"123":[],"456":[]}', true);
$newUtenti = ["789" => []];
$newUtenti = array_merge($utenti, $newUtenti);

echo json_encode($newUtenti);

What am I doing wrong?
This is the expected output: {"123":[],"456":[], "789": []}

0

There are 0 best solutions below