Answer the question
In order to leave comments, you need to log in
How to add/change file text with file_put_contents in the middle of content?
For example, there is a json file with the following content:
[
{
"some": 1
}
]
"some": 1
"some": 2
Answer the question
In order to leave comments, you need to log in
file_put_contents - writes to a file. So take what you write to a file and replace it as in normal json.
1. Read the file
2. Parse json
3. Change the required data
4. Convert json to a string
5. Write to file
No modification in the middle of the file will work, only overwrite the entire file. Especially json.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question