Skip to content
Advertisement

How can I read/ write to a single array in json with PHP

I have a simple script that can store data in a json file. Every time you save the form it creates a new array. I just want to update goal and raised in the same array.

form:

JavaScript

process.php

JavaScript

Advertisement

Answer

array_push appends. You want to replace existing, not add, right? So:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement