Reputation: 31
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,
Upvotes: 0
Views: 69
Reputation: 713
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));
Upvotes: 2