I'm confused, cannot add correctly new objects to the json object:
$old_json = json_decode(file_get_contents("file.json"), true);
$new_json = ' { "1" : "111", "2" : "222" } ';
$old_json[] = $new_json;
file_put_contents("file.json", stripslashes(json_encode($old_json)));
it will replace the old records with new records, but I want just to add new record. I want it to write new json file with below content:
[{"a":"aaa","b","bbb"},{"1":"111","2":"222"}]
Please tell me how to achieve the right results. Also please show me how I can access new json object after json_decode()
Thanks.