I want to write JSON data to a file using PHP. I already written { } in the file. I tried to write data in between the curly braces using fseek function. But its not working.
Thanks,
I want to write JSON data to a file using PHP. I already written { } in the file. I tried to write data in between the curly braces using fseek function. But its not working.
Thanks,
Using Json_encode for your array instead of writing { } or any other characters:
$array = array("Name" => "Ali" , "Lastname" =>"Gutmanz");
file_put_contents("test.txt" , json_encode($array));
file_put_contents('test.txt', json_encode($array), FILE_APPEND). However, your just going to be adding the whole JSON over and over as separate strings. If your trying to open the json up and add into it's data, instead of adding over and over, then I would say your a bit over your head...