Answer the question
In order to leave comments, you need to log in
How to add key-value pair to json array in php?
there is a json file with such content
how to add values to such an array in php?
For example, add AUDUSD with value 22
I know how to start and end, but how to directly add values so that the array structure is preserved.{"EURUSD":25,"GBPCAD":10,"EURCAD":18}
$file1 = file_get_contents('data.json');
$list1 = json_decode($file1,TRUE);
unset($file1);
$result = [];
//здесь должно быть добавление записи.
file_put_contents('data.json',json_encode($result));
echo "Успех";
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question