Answer the question
In order to leave comments, you need to log in
How to write to JSON without overwriting?
Good evening. There is a problem when writing to a JSON file:
there is a code
$arrayApi = array('date'=>$datetime[0], 'time'=>$datetime[1], 'price'=>$date[0]['price'], 'discount_price'=>$date[0]['discount_price'], 'is_free'=>$date[0]['is_free']);
$res = json_encode($arrayApi);
file_put_contents("1.json",$res);
{"date":"2017-05-31","time":"02:00:00","price":"4000","discount_price":"3000","is_free":"1"}
{"date":"2017-05-30","time":"00:00","price":5000,"discount_price":4000,"is_free":false},{"date":"2017-05-30","time":"01:30","price":5000,"discount_price":4000,"is_free":false},{"date":"2017-05-30","time":"03:00","price":5000,"discount_price":4000,"is_free":false}
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