Skip to content
Advertisement

I can’t generate the correct Json file in PHP

it does not work properly please help me to get the correct json file?

in particular when I inserted it in the site in php I got this array so the Json file creates it correctly

this is the first array I generate via submit of my form. this array I add it to the end of the Json file, but I get an unwanted result.

JavaScript

get such a formatted array and that’s no good!

JavaScript

This is the result I have to get a simple json file like the one below

JavaScript

Advertisement

Answer

I’m not sure why you are over-complicating things in your code like that. If you just want to append the posted data you could use the following snippet

JavaScript

I’d strongly suggest you to verify the submitted data first before saving/appending to the JSON file

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