Jeeva
Jeeva

Reputation: 31

Write data to file using PHP

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

Answers (1)

Alex
Alex

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

Related Questions