I have tried everything and it is probably very simple to solve. I want to add to a JSON object. I have searched and found examples but it does not yield the results I want. I have a JSON object that looks like this
{"d86":"2020-03-04","d76":"2020-03-05"}
Now I want to append to this so it looks like this
{"d86":"2020-03-04","d76":"2020-03-05","d97":"2020-05-08"}
The examples of how to do this give me this result
{"d86":"2020-03-04","d76":"2020-03-05","0":{"d97":"2020-03-08"}}
This is my code:
$j = array('d86'=>'2020-03-04','d76'=>'2020-03-05');
$j = json_encode($j);
$j = json_decode($j, true);
$new_date = array('d97'=>'2020-03-08');
$j[] = $new_date;
$j = json_encode($j);
print_r($j);